我想通過這種方法來獲得從地址緯度和經度: -java.lang.NoClassDefFoundError:失敗分辨率:LCOM /谷歌/安卓/地圖/ GeoPoint的
public GeoPoint getLocationFromAddress(String strAddress){
Geocoder coder = new Geocoder(this);
List<Address> address;
GeoPoint p1 = null;
try {
address = coder.getFromLocationName(strAddress,5);
if (address==null) {
return null;
}
Address location=address.get(0);
location.getLatitude();
location.getLongitude();
p1 = new GeoPoint((int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
return p1;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
但我得到這個錯誤: -
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/maps/GeoPoint
我在這裏錯過了什麼?
我的全錯誤: -
Process: breamex.happy_week_end, PID: 22803 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/maps/GeoPoint; at breamex.happy_week_end.search.SearchActivity.getLocationFromAddress(SearchActivity.java:439) at breamex.happy_week_end.search.SearchActivity.search(SearchActivity.java:357) at breamex.happy_week_end.search.SearchActivity.access$000(SearchActivity.java:76) at breamex.happy_week_end.search.SearchActivity$1.onClick(SearchActivity.java:189) at android.view.View.performClick(View.java:5610) at android.view.View$PerformClick.run(View.java:22265) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.maps.GeoPoint" on path: DexPathList[[zip file "/data/app
我的全搖籃: -
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:24'
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "app"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':stepper')
compile project(':slider')
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.22.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.android.support:support-v4:26.+'
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.jakewharton:butterknife:8.6.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
發表您的完整的錯誤日誌和gradle這個文件 –
@BhuvaneshBs什麼gradle這個會爲你順便說一句,我沒有用它做?這主要錯誤,沒有更多有用的東西? –
你不能定義這是一個確切的錯誤。這個錯誤可能是由其他一些原因造成的。所以發佈完整的錯誤日誌。 –