Android Question TargetSdkVersion 28 is error

Status
Not open for further replies.

rscheel

Well-Known Member
Licensed User
Longtime User
Hi dear, I changed targetSdkVersion from 27 to 28 to test and it turns out that I get an error when starting the application, in configuration of routes I'm pointing to \ platforms \ android-28 \ android.jar, I'm using a Xiaomi Mi Mix 2s with Android 9

B4X:
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
    at fa.b(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-217905028):3)
    at ez.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-217905028):3)
    at fb.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-217905028):15)
    at com.google.maps.api.android.lib6.drd.al.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-217905028):6)
    at ee.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-217905028):21)
    at ee.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-217905028):8)
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/0000002d/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/0000002d/MapsDynamite.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at ac.loadClass(:com.google.android.gms.dynamite_dynamiteloader@[email protected] (100400-217905028):4)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 6 more

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
Are you using an old version of http or httputils library?

Switch to okhttp and okhttputils2

Upload a project which shows the issue
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
Maybe it is OSMDroid lib or polygonraycast library which does a download internally using old HTTP Resources!?
The others, i think, we can ignore about this issue.

Specify requirement for Apache HTTP Legacy library
If your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the

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

https://developers.google.com/maps/...fy_requirement_for_apache_http_legacy_library
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This is a bug on the Google Play Services side, until it's fixed, you should be able to workaround by adding this to your AndroidManifest.xml inside the <application> tag:

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

rscheel

Well-Known Member
Licensed User
Longtime User
This is a bug on the Google Play Services side, until it's fixed, you should be able to workaround by adding this to your AndroidManifest.xml inside the <application> tag:

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

In which part of the manifest should I add that line.
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
Add the line, now I get the following error, the application now does not close

B4X:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to (ip) not permitted by network security policy, Response:
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
HOW DID you add it???????
Did you just insert it as is in the manifest???

This is how the manifest was


B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
    )
'SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:icon, "@mipmap/ic_launcher")
CreateResource(mipmap-anydpi-v26, ic_launcher.xml,
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@mipmap/background"/>
    <foreground android:drawable="@mipmap/foreground"/>
</adaptive-icon>
)
'CreateResourceFromFile(Macro, Themes.DarkTheme)
'End of default text.

AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)

AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="API-KEY"/>
   <meta-data android:name="com.google.android.gms.version"
   android:value="@integer/google_play_services_version" />
  
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />)

'Tema Aplicación
SetApplicationAttribute(android:theme, "@style/MyAppTheme")

CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#000000</item>
        <item name="colorPrimaryDark">#000000</item>
        <item name="colorAccent">#2962FF</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
        <item name="asp_preferenceIconTint">?colorAccent</item>
        <item name="asp_preferenceDialogIconTint">?asp_preferenceIconTint</item>
        <item name="windowActionModeOverlay">true</item>
    </style>
</resources>)
 
Upvote 0

German Buchmuller

Member
Licensed User
Longtime User
It is currently not recommended to set targetSdkVersion to 28. It should be set to 26.
Im getting same error here. Targetsdkversion 26 solves de problem, but must use 28 on August onwards right? What should I do? Some devices (specially Galaxy s9+) Crashes just by opening the app. Play console error:

B4X:
java.lang.NoClassDefFoundError:
  at gt.b (com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-248795830):3)
  at gu.a (com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-248795830):3)
  at gw.a (com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-248795830):14)
  at com.google.maps.api.android.lib6.drd.aj.a (com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-248795830):6)
  at fy.a (com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-248795830):22)
  at fy.run (com.google.android.gms.dynamite_mapsdynamite@[email protected] (100400-248795830):8)
Caused by: java.lang.ClassNotFoundException:
  at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
  at ab.loadClass (com.google.android.gms.dynamite_dynamiteloader@[email protected] (100400-248795830):4)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
 
Upvote 0
Status
Not open for further replies.
Top