1

I'd like to use few hidden properties in my project and I am able to do it if I replace the default $SDK_PATH/platforms/android-27/android.jar for android.jar with exposed properties but every time I want to work on this project, I need to manually replace that android.jar file for another and then replace it for the original one.

I've found there's a way to include the exposed android.jar file via gradle (source e.g.: here) by adding it to its dependencies. So I've done it:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    compileOnly files('platform/android-27/android.jar')
    implementation 'com.android.support:appcompat-v7:27.1.1'
}

I can do gradle sync, gradle can see the file but building the project fails with error: cannot find symbol variable INSTALL_REPLACE_EXISTING.

The code I'm using the variable (constant actually) in:

File file = new File(apkPath);
pm.installPackage(Uri.fromFile(file), observer, PackageManager.INSTALL_REPLACE_EXISTING, "com.example.pminstaller");

Please, what else should I do to make it work?

EDIT: I've moved a bit with this problem. I can find classes like EthernetManager, which are hidden in default SDK but I can't use hidden methods from classes which are not hidden in default SDK. After adding android.jar file with hidden API, the project have two classes with the same package name and it selects the default one.

How can I force gradle to select the hidden one?

Community
  • 1
  • 1
Jakub Turcovsky
  • 2,096
  • 4
  • 30
  • 41
  • What do you mean by "I'd like to use a few hidden properties"? Can you give an example? Are you trying to call private methods? If so, that sounds like a bad idea. – EJK Aug 14 '18 at 15:15
  • Please see the code. I'm trying to use hidden method PackageManager.installPackage() and constant PackageManager.INSTALL_REPLACE_EXISTING. And I know it's deprecated. I don't look for an alternative, I look for solution. I could run to this later and I want to know how to solve it based on result of this one. – Jakub Turcovsky Aug 14 '18 at 16:03

0 Answers0