当我在模拟器上测试我的应用程序时,它工作正常,但是当我在真正的 android 10.0(版本)手机上运行该应用程序时,log-cat 显示我根本无法理解的错误。这是非常令人困惑的,因为它在一部手机(较低版本)上运行良好,但在另一部手机(Android 10.0 版本)上不起作用。
我收到的错误如下:
反编译的.class文件,确切地说是字节码版本52.00(Java 8)。
错误选项卡中的 Logcat:
2020-02-18 22:08:23.114 22232-22280/? E/AndroidRuntime: FATAL EXCEPTION: Thread-4
Process: com.atmosphericproductiveinnovations.worldage, PID: 22232
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at bt.b(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):2)
at bs.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):2)
at bu.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):17)
at com.google.maps.api.android.lib6.drd.ak.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):5)
at ay.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):8)
at ay.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):44)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/000000f6/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/000000f6/MapsDynamite.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at dalvik.system.DelegateLastClassLoader.loadClass(DelegateLastClassLoader.java:137)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at bt.b(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):2)
at bs.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):2)
at bu.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):17)
at com.google.maps.api.android.lib6.drd.ak.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):5)
at ay.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):8)
at ay.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] /cdn-cgi/l/email-protection (120400-0):44)
2020-02-18 22:08:23.128 22232-22232/? E/libprocessgroup: set_timerslack_ns write failed: Operation not permitted
2020-02-18 22:08:23.206 22232-22232/? E/BufferQueueConsumer: disconnect by : com.atmosphericproductiveinnovations.worldage my_pid = 22232
地图活动.Java:
package com.atmosphericproductiveinnovations.worldage;
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng India = new LatLng(23.52, 78.59);
mMap.addMarker(new MarkerOptions()
.position(India)
.title("India"))
//.setSnippet("Meow. My name is");
.setSnippet("Information-"+"" +
"\n"+"Location:South Asia"+
"\n"+"Population:133.92 crores (2017)"+
"\n"+"GDP:2.6 lakh crores USD (2017):");
mMap.moveCamera(CameraUpdateFactory.newLatLng(India));
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(MapsActivity.this));
}
}
Android 清单 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.atmosphericproductiveinnovations.worldage">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD7EYViNqAco_PXl-0CyCgJ6l2eEIzvTzY" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
BaseDexClassLoader.class:
package dalvik.system;
import java.io.File;
import java.net.URL;
import java.util.Enumeration;
public class BaseDexClassLoader extends ClassLoader {
public BaseDexClassLoader(String dexPath, File optimizedDirectory, String librarySearchPath, ClassLoader parent) {
throw new RuntimeException("Stub!");
}
protected Class<?> findClass(String name) throws ClassNotFoundException {
throw new RuntimeException("Stub!");
}
protected URL findResource(String name) {
throw new RuntimeException("Stub!");
}
protected Enumeration<URL> findResources(String name) {
throw new RuntimeException("Stub!");
}
public String findLibrary(String name) {
throw new RuntimeException("Stub!");
}
protected synchronized Package getPackage(String name) {
throw new RuntimeException("Stub!");
}
public String toString() {
throw new RuntimeException("Stub!");
}
}
DelegateLastClassLoader.class:
package dalvik.system;
import android.annotation.NonNull;
import android.annotation.Nullable;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
public final class DelegateLastClassLoader extends PathClassLoader {
public DelegateLastClassLoader(String dexPath, ClassLoader parent) {
super((String)null, (ClassLoader)null);
throw new RuntimeException("Stub!");
}
public DelegateLastClassLoader(String dexPath, String librarySearchPath, ClassLoader parent) {
super((String)null, (ClassLoader)null);
throw new RuntimeException("Stub!");
}
public DelegateLastClassLoader(@NonNull String dexPath, @Nullable String librarySearchPath, @Nullable ClassLoader parent, boolean delegateResourceLoading) {
super((String)null, (ClassLoader)null);
throw new RuntimeException("Stub!");
}
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
throw new RuntimeException("Stub!");
}
public URL getResource(String name) {
throw new RuntimeException("Stub!");
}
public Enumeration<URL> getResources(String name) throws IOException {
throw new RuntimeException("Stub!");
}
}
我是 IntelliJ 新手