Home » Android » android – How can I fix error "decompiled .class file bytecode version 52.0 (Java 8)-Exceptionshub

android – How can I fix error "decompiled .class file bytecode version 52.0 (Java 8)-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

When I test my app on the emulator it works fine but when I ran the application on a real android 10.0 (Version) phone the log-cat shows errors which i can’t understand at all. It is very confusing as it works fine on one phone (A lower version) and does not work on the other phone (Android 10.0 version).

The errors which I receive are the following:

Decompiled .class file, byte code version 52.00(Java 8) to be exact.

Logcat in error tab:

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(:[email protected]@20.1.04 (120400-0):2)
        at bs.a(:[email protected]@20.1.04 (120400-0):2)
        at bu.a(:[email protected]@20.1.04 (120400-0):17)
        at com.google.maps.api.android.lib6.drd.ak.a(:[email protected]@20.1.04 (120400-0):5)
        at ay.a(:[email protected]@20.1.04 (120400-0):8)
        at ay.run(:[email protected]@20.1.04 (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(:[email protected]@20.1.04 (120400-0):2) 
        at bs.a(:[email protected]@20.1.04 (120400-0):2) 
        at bu.a(:[email protected]@20.1.04 (120400-0):17) 
        at com.google.maps.api.android.lib6.drd.ak.a(:[email protected]@20.1.04 (120400-0):5) 
        at ay.a(:[email protected]@20.1.04 (120400-0):8) 
        at ay.run(:[email protected]@20.1.04 (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

MapsActivity.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 manifest xml file:

<?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!");
    }
}

I am new to IntelIJ

How to&Answers:

If you are using com.google.android.gms:play-services-maps:16.0.0 or
below and your app is targeting API level 28 (Android 9.0) or above,
you must include the following declaration within the
element of AndroidManifest.xml.

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

This is handled for you if you are using
com.google.android.gms:play-services-maps:16.1.0 and is not necessary
if your app is targeting a lower API level.

specify requirement for apache http legacy library