Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] gradle build of android project using hidden apis: fails in some build environments and succeeds in others

Posted on November 11, 2022 By

Solution 1 :

I was able to fix my problem as follows:

  1. Uninstall all versions in my SDK for build-tools:
$ANDROID_HOME/tools/bin/sdkmanager --uninstall "build-tools;28.0.3"
$ANDROID_HOME/tools/bin/sdkmanager --uninstall "build-tools;29.0.2"
  1. I then installed build-tools;27.0.2

`$ANDROID_HOME/tools/bin/sdkmanager –install “build-tools;27.0.2”

  1. Then I just did my gradle build: ./gradlew clean assembleRelease

This automatically downloaded and installed build-tools;28.0.3 as my gradle projects specify it for targetSdkVersion and compileSdkVersion> And the build was successful!

I believe in all of above steps removal of the build-tools;29.0.2 was the most significant part. Is suspect that version of build-tools adds additional pesky checks to fail compilation.

NOTE: I had to switch to JDK 8 to run sdkmanager

Problem :

I have an android project that uses some hidden API (e plan to fix this in future but not now).

The same master branch of the project’s git repo builds fine is some build environments but gives compile errors in some build environment on the lines of code that use the hidden api.

The command I use in both environment is: ./gradlew clean assembleRelease

In one environment it builds fine. In another environment it gives compile errors like:

> Task :myproject:compileReleaseJavaWithJavac FAILED
/home/farrukh/myproject/src/main/java/com/mycompany/myproject/MyClass.java:4: error: cannot find symbol
import android.os.SystemProperties;
                 ^
  symbol:   class SystemProperties
  location: package android.os
/home/farrukh/myproject/src/main/java/com/mycompany/myproject/MyClass.java:82: error: cannot find symbol
            partNumber = SystemProperties.get("ro.boot.partnumber", null);
                         ^
  symbol:   variable SystemProperties
  location: class MyClass
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

In both cases the Android SDK has Android 9.0 (API 28) installed but the specific sub-version could be different.

In the environment where the build fails the following info is generated from sdkmanager --list:

Path                 | Version | Description                    | Location             
  -------              | ------- | -------                        | -------              
  build-tools;28.0.3   | 28.0.3  | Android SDK Build-Tools 28.0.3 | build-tools/28.0.3/  
  build-tools;29.0.2   | 29.0.2  | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2/  
  emulator             | 30.0.0  | Android Emulator               | emulator/            
  patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4/          
  platform-tools       | 29.0.6  | Android SDK Platform-Tools     | platform-tools/      
  platforms;android-18 | 3       | Android SDK Platform 18        | platforms/android-18/
  platforms;android-23 | 3       | Android SDK Platform 23        | platforms/android-23/
  platforms;android-24 | 2       | Android SDK Platform 24        | platforms/android-24/
  platforms;android-26 | 2       | Android SDK Platform 26        | platforms/android-26/
  platforms;android-27 | 3       | Android SDK Platform 27        | platforms/android-27/
  platforms;android-28 | 6       | Android SDK Platform 28        | platforms/android-28/
  platforms;android-29 | 4       | Android SDK Platform 29        | platforms/android-29/
  sources;android-28   | 1       | Sources for Android 28         | sources/android-28/  
  sources;android-29   | 1       | Sources for Android 29         | sources/android-29/  
  tools                | 26.1.1  | Android SDK Tools              | tools/       

The environment where it works is a Jenkins build wher sdkmanager --list shows the following:

Installed packages:
  Path                        | Version | Description                    | Location                    
  -------                     | ------- | -------                        | -------                     
  build-tools;27.0.1          | 27.0.1  | Android SDK Build-Tools 27.0.1 | build-tools/27.0.1/         
  build-tools;27.0.2          | 27.0.2  | Android SDK Build-Tools 27.0.2 | build-tools/27.0.2/         
  emulator                    | 29.0.11 | Android Emulator               | emulator/                   
  extras;android;m2repository | 47.0.0  | Android Support Repository     | extras/android/m2repository/
  extras;google;m2repository  | 58      | Google Repository              | extras/google/m2repository/ 
  patcher;v4                  | 1       | SDK Patch Applier v4           | patcher/v4/                 
  platform-tools              | 29.0.1  | Android SDK Platform-Tools     | platform-tools/             
  tools                       | 26.1.1  | Android SDK Tools              | tools/   

Any idea what could cause the difference in build behavior?

READ  [FIXED] java - Using `when` should return different values
Powered by Inline Related Posts

Could the difference in Build Tools version (working env has 27.0.1, while not working env has 28.0.3) cause this difference?

UPDATE: Two very similar jenkins job built with same android SDK packages listed just above produce similar different result where one compiles the code fine and another fails to compile code using hidden apis. So the difference is not the SDK package versions. What else should I look for as difference between working and not working environment?

Android Tags:android, gradle

Post navigation

Previous Post: [FIXED] java – How to solve debug issue
Next Post: [FIXED] android – How to solve setting up this payment problem – paypal

Related Posts

[FIXED] java – Exception on OnItemClicked.onItemClick(int) on a null object refrence? Android
[FIXED] android – How to have 2 different previews running on Camera2 Api? Android
[FIXED] android – Xamarin – Permission “REQUEST_INSTALL_PACKAGES” – Which dependency brings this permission Android
[FIXED] android – java.lang.IllegalStateException: Already attached at androidx.fragment.app.FragmentManagerImpl.attachController – Android
[FIXED] java – RecylerView not updating new data unless the emulator is refreshed by turning on and off Android
[FIXED] java – How can i make a Button in android appear in a fixed position and always in front of all other views? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is a good substitute for condensed milk?
  • ¿Como el cuerpo te avisa cuando te va a dar un infarto?
  • What is the luxury brand of Jaguar?
  • Who is Big poppa baseball player?
  • What material are foam runners?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme