2

I found an example of using OTA updates. But i need to use android.os.UpdateEngine

This is SystemApi, and i found this question on StackOverFlow, where answer is wrote to android.mk file LOCAL_SDK_VERSION := system_current

I never worked with android.mk files before, so i created it and put to app/android.mk

This is all that i have in mine android.mk file:

LOCAL_PATH := $(call my-dir)
LOCAL_SDK_VERSION := system_current

Also i add this to build.gradle file (i dont use NDK in my app, but i dont know another ways to use android.mk file)

sourceSets.main {
        jniLibs.srcDir 'src/main/libs' //set libs as .so's location instead of jniLibs
        jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk
    }
externalNativeBuild {
        ndkBuild {
            path 'Android.mk'
        }
    }

But anyway, when i writing import android.os.UpdateEngine i'm getting Cannot resolve symbol "UpdateEngine"

I was trying to search on Stack, Google, but cannot find solution.

5
  • Did you ever find a solution? Commented Nov 14, 2018 at 10:27
  • @SimonRaes yeah, i found solution Commented Nov 14, 2018 at 11:09
  • @SimonRaes, contact me in telegram "@student_in" Commented Nov 14, 2018 at 11:15
  • Can you add it as an answer to your question? That way others can use it too. Commented Nov 14, 2018 at 14:16
  • @SimonRaes there is a lot of code, i will post it on my own blog, check in few days Commented Nov 14, 2018 at 16:13

1 Answer 1

4

I got it working without a makefile or the NDK by using the modified android.jar file from this repo: https://github.com/anggrayudi/android-hidden-api

Download the appropriate android.jar file and place it at app/libs-sdk in your project.

Add the following dependency to your app build.gradle file:

compileOnly fileTree(include: ['*.jar'], dir: 'libs-sdk')

In the top level build.gradle file add the following code to make Android Studio use the modified android.jar.

allprojects {
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs.add('-Xbootclasspath/p:/android.jar')
        }
    }
}

After these steps I could access the android.os.UpdateEngine class from my project. The only issue this does not fix is accessing some SystemApi methods (not classes) such as RecoverySystem#verifyPackageCompatibility.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.