我知道有很多這樣的問題,但我找不到任何有用的接受答案。Intellij Android應用程序中的谷歌地圖15
我試圖(和其他幾個人也):
- stackoverflow.com/questions/17960315/importing-google-play-services-lib-into-intellij-idea-12-and- 17977734分之13#17977734
- stackoverflow.com/questions/14372391/java-lang-noclassdeffounderror-com-google-android-gms-rstyleable/15826818#15826818
- stackoverflow.com/questions/14002488/google-play- services-library-in-intellij-12
但到目前爲止,沒有任何工作......我不知道這是智能問題還是我的問題。
這裏有一些截圖
i.stack.imgur.com/Wfm9k.png
i.stack.imgur.com/bcShb.png
i.stack.imgur.com/ SNkSZ.png
我試過把它作爲一個模塊直接從android-sdk/extras/....導入,我試圖複製粘貼到我的工作區中的整個google-services項目沒有任何作用。屏幕截圖僅來自我發現並嘗試的最後一個setUp(教程/答案)。
這是當前的錯誤:
java.lang.RuntimeException: Unable to start activity ComponentInfo{hci4.project.FriendsWithCars/hci4.project.FriendsWithCars.MainActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
Caused by: android.app.Fragment$InstantiationException: Trying to instantiate a class com.google.android.gms.maps.SupportMapFragment that is not a Fragment
請幫助我。
EDIT 1: 以下是在一個新設置新的錯誤....
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
public class MainActivity extends Activity {
private GoogleMap map;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
// Testing
TextView tv = (TextView) findViewById(R.id.TESTING);
DBHandler db = DBHandler.getInstance(this);
String output = db.getFullDB();
tv.setText(output);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
}
}
這裏是main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/TESTING"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, MainActivity"
/>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
錯誤:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/R$styleable;
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.R$styleable" on path: DexPathList[[zip file "/data/app/hci4.project.FriendsWithCars-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.R$styleable
最快的解決辦法:下載Android工作室:) –