我在运行应用时面临未知问题。我尝试了很多次谷歌找到解决方案,但没有任何链接帮助我。 我想要的是在用户点击名为get coordinate button的正按钮时显示谷歌地图 帮助!
Set_Coordinate.java
public class Set_Coordinates extends FragmentActivity{
private static final int GPS_ERRORDIALOG_REQUEST = 9001;
GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(servicesOK()){
Toast.makeText(this, "Ready to map!", Toast.LENGTH_SHORT).show();
setContentView(R.layout.activity_map);
}
else{
setContentView(R.layout.set_coordinates);
}
}
public boolean servicesOK(){
int isAvaliable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (isAvaliable == ConnectionResult.SUCCESS){
return true;
}
else if (GooglePlayServicesUtil.isUserRecoverableError(isAvaliable)){
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvaliable, this, GPS_ERRORDIALOG_REQUEST);
dialog.show();
}
else{
Toast.makeText(this, "Can't connect to Google Play Services", Toast.LENGTH_SHORT).show();
}
return false;
}
}
这是activity_map.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
这是清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nabia.mutemehere"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="21" />
<permission
android:name="com.nabia.mutemehere.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name= "com.nabia.mutemehere.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Set_Location"
android:theme="@android:style/Theme.Black"
/>
<activity android:name=".Set_time"
android:theme="@android:style/Theme.Holo"/>
<activity android:name=".Set_Phone_Setting"/>
<activity android:name=".Set_Profile"/>
<activity android:name=".Set_Coordinates"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBf_4hA3cRa6qBkJuKKjEv1q4wXOnwwkT8"/>
</application>
</manifest>
这是我的LogCat文件
09-07 15:28:57.776: E/Zygote(12792): MountEmulatedStorage()
09-07 15:28:57.776: E/Zygote(12792): v2
09-07 15:28:57.776: I/SELinux(12792): Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_GT-I9500_5.0.1_0009
09-07 15:28:57.776: I/libpersona(12792): KNOX_SDCARD checking this for 10200
09-07 15:28:57.776: I/libpersona(12792): KNOX_SDCARD not a persona
09-07 15:28:57.786: E/SELinux(12792): [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
09-07 15:28:57.786: I/art(12792): Late-enabling -Xcheck:jni
09-07 15:28:58.601: D/ResourcesManager(12792): creating new AssetManager and set to /data/app/com.nabia.mutemehere-1/base.apk
09-07 15:28:58.606: W/ResourcesManager(12792): Asset path '/system/framework/com.google.android.maps.jar' does not exist or contains no resources.
09-07 15:28:58.666: V/BitmapFactory(12792): DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/ic_ab_back_holo_dark_am.png
09-07 15:28:58.681: V/BitmapFactory(12792): DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/sym_def_app_icon.png
09-07 15:28:58.696: V/BitmapFactory(12792): DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/ic_launcher.png
09-07 15:28:58.701: D/Activity(12792): performCreate Call secproduct feature valuefalse
09-07 15:28:58.701: D/Activity(12792): performCreate Call debug elastic valuetrue
09-07 15:28:58.721: D/OpenGLRenderer(12792): Render dirty regions requested: true
09-07 15:28:58.746: D/Atlas(12792): Validating map...
09-07 15:28:58.756: V/ActivityThread(12792): updateVisibility : ActivityRecord{266d0a77 token=android.os.BinderProxy@3eabb11 {com.nabia.mutemehere/com.nabia.mutemehere.MainActivity}} show : true
09-07 15:28:58.886: I/OpenGLRenderer(12792): Initialized EGL, version 1.4
09-07 15:28:58.886: W/OpenGLRenderer(12792): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
09-07 15:28:58.911: D/OpenGLRenderer(12792): Get maximum texture size. GL_MAX_TEXTURE_SIZE is 4096
09-07 15:28:58.911: D/OpenGLRenderer(12792): Enabling debug mode 0
09-07 15:28:58.916: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:28:58.921: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:28:58.921: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:28:58.926: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:29:04.201: I/Choreographer(12792): Skipped 278 frames! The application may be doing too much work on its main thread.
09-07 15:29:04.506: I/Timeline(12792): Timeline: Activity_idle id: android.os.BinderProxy@3eabb11 time:180392486
09-07 15:29:05.376: I/Choreographer(12792): Skipped 43 frames! The application may be doing too much work on its main thread.
09-07 15:29:05.501: W/IInputConnectionWrapper(12792): showStatusIcon on inactive InputConnection
09-07 15:29:06.316: I/Timeline(12792): Timeline: Activity_idle id: android.os.BinderProxy@3eabb11 time:180394297
09-07 15:29:08.721: D/ViewRootImpl(12792): ViewPostImeInputStage ACTION_DOWN
09-07 15:29:08.796: I/Timeline(12792): Timeline: Activity_launch_request id:com.nabia.mutemehere time:180396776
09-07 15:29:09.191: D/Activity(12792): performCreate Call secproduct feature valuefalse
09-07 15:29:09.191: D/Activity(12792): performCreate Call debug elastic valuetrue
09-07 15:29:09.236: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:29:09.241: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:29:09.241: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:29:09.241: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 1920
09-07 15:29:09.561: V/RenderScript(12792): 0xaf807200 Launching thread(s), CPUs 2
09-07 15:29:09.616: I/Timeline(12792): Timeline: Activity_idle id: android.os.BinderProxy@295f8a81 time:180397599
09-07 15:29:10.026: V/ActivityThread(12792): updateVisibility : ActivityRecord{266d0a77 token=android.os.BinderProxy@3eabb11 {com.nabia.mutemehere/com.nabia.mutemehere.MainActivity}} show : false
09-07 15:29:13.011: D/ViewRootImpl(12792): ViewPostImeInputStage ACTION_DOWN
09-07 15:29:15.871: D/ViewRootImpl(12792): ViewPostImeInputStage ACTION_DOWN
09-07 15:29:16.051: V/BitmapFactory(12792): DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/ic_dialog_info.png
09-07 15:29:16.136: V/BitmapFactory(12792): DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/bottom_bar.png
09-07 15:29:16.246: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 485
09-07 15:29:16.261: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 485
09-07 15:29:16.261: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 485
09-07 15:29:16.261: E/(12792): [android_ws] Format: 5, Width: 1080, Height: 485
09-07 15:29:17.361: D/ViewRootImpl(12792): ViewPostImeInputStage ACTION_DOWN
09-07 15:29:17.576: I/art(12792): Rejecting re-init on previously-failed class java.lang.Class<com.nabia.mutemehere.Set_Coordinates>
09-07 15:29:17.576: I/art(12792): Rejecting re-init on previously-failed class java.lang.Class<com.nabia.mutemehere.Set_Coordinates>
09-07 15:29:17.581: D/AndroidRuntime(12792): Shutting down VM
09-07 15:29:17.581: E/AndroidRuntime(12792): FATAL EXCEPTION: main
09-07 15:29:17.581: E/AndroidRuntime(12792): Process: com.nabia.mutemehere, PID: 12792
09-07 15:29:17.581: E/AndroidRuntime(12792): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/nabia/mutemehere/Set_Coordinates;
09-07 15:29:17.581: E/AndroidRuntime(12792): at com.nabia.mutemehere.Set_Location$1$1.onClick(Set_Location.java:31)
09-07 15:29:17.581: E/AndroidRuntime(12792): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:162)
09-07 15:29:17.581: E/AndroidRuntime(12792): at android.os.Handler.dispatchMessage(Handler.java:102)
09-07 15:29:17.581: E/AndroidRuntime(12792): at android.os.Looper.loop(Looper.java:145)
09-07 15:29:17.581: E/AndroidRuntime(12792): at android.app.ActivityThread.main(ActivityThread.java:5942)
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.reflect.Method.invoke(Native Method)
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.reflect.Method.invoke(Method.java:372)
09-07 15:29:17.581: E/AndroidRuntime(12792): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
09-07 15:29:17.581: E/AndroidRuntime(12792): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
09-07 15:29:17.581: E/AndroidRuntime(12792): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.nabia.mutemehere.Set_Coordinates" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.nabia.mutemehere-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
09-07 15:29:17.581: E/AndroidRuntime(12792): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
09-07 15:29:17.581: E/AndroidRuntime(12792): ... 9 more
09-07 15:29:17.581: E/AndroidRuntime(12792): Suppressed: java.lang.NoClassDefFoundError: com.nabia.mutemehere.Set_Coordinates
09-07 15:29:17.581: E/AndroidRuntime(12792): at dalvik.system.DexFile.defineClassNative(Native Method)
09-07 15:29:17.581: E/AndroidRuntime(12792): at dalvik.system.DexFile.defineClass(DexFile.java:226)
09-07 15:29:17.581: E/AndroidRuntime(12792): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
09-07 15:29:17.581: E/AndroidRuntime(12792): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
09-07 15:29:17.581: E/AndroidRuntime(12792): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
09-07 15:29:17.581: E/AndroidRuntime(12792): ... 11 more
09-07 15:29:17.581: E/AndroidRuntime(12792): Suppressed: java.lang.ClassNotFoundException: com.nabia.mutemehere.Set_Coordinates
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.Class.classForName(Native Method)
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
09-07 15:29:17.581: E/AndroidRuntime(12792): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
09-07 15:29:17.581: E/AndroidRuntime(12792): ... 10 more
09-07 15:29:17.581: E/AndroidRuntime(12792): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
答案 0 :(得分:0)
你有一个NoClassDefFoundError,这意味着你声明的内容和你实际使用的内容有问题。
您的文件名Set_Coordinate
。java与您的类声明不同
public class Set_Coordinates
扩展了FragmentActivity {