gpt4 book ai didi

java.lang.NoClassDefFoundError : Failed resolution of: Lcom/google/android/maps/GeoPoint

转载 作者:行者123 更新时间:2023-12-02 12:21:05 29 4
gpt4 key购买 nike

我正在尝试通过此方法从地址获取纬度和经度:-

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

我完整的Gradle:-

 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'

最佳答案

您必须在应用程序中包含multiDex。请参阅错误日志中的以下错误。

ClassNotFoundException: Didn't find class "com.google.android.maps.GeoPoint" on path: DexPathList[[zip file "/data/app

将其添加到您的依赖项中。

compile 'com.android.support:multidex:1.0.1'

在你的 Gradle 中添加 multiDexEnabled true

android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true // add this line
}
...
}

在 list 中添加 multiDex 应用程序类。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>

然后清理并重建您的项目。

希望对您有所帮助:)

关于java.lang.NoClassDefFoundError : Failed resolution of: Lcom/google/android/maps/GeoPoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45780465/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com