如何修复错误“反编译的 .class 文件字节码版本 52.0 (Java 8)

2024-01-14

当我在模拟器上测试我的应用程序时,它工作正常,但是当我在真正的 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 新手


如果您使用 com.google.android.gms:play-services-maps:16.0.0 或 以下且您的应用的目标 API 级别为 28 (Android 9.0) 或更高版本, 您必须在其中包含以下声明 AndroidManifest.xml 的元素。

<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />

如果您正在使用,这将为您处理 com.google.android.gms:play-services-maps:16.1.0 并且不是必需的 如果您的应用程序的目标是较低的 API 级别。

指定 apache http 遗留库的要求 https://developers.google.com/maps/documentation/android-sdk/config#specify_requirement_for_apache_http_legacy_library

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何修复错误“反编译的 .class 文件字节码版本 52.0 (Java 8) 的相关文章

随机推荐