I try to move android TV app to Android studio. When I try to compile it, I had some import errors. I couldn't find the dependency that I can add to build.gradle to fix these problem. The list of the imports are:
import android.media.tv.TvContentRatingSystemInfo;
import android.media.tv.TvContract.WatchedPrograms;
import com.android.tv.tuner.data.nano.Track.AtscCaptionTrack;
import com.android.tv.tuner.data.nano.Track.AtscAudioTrack;
import com.android.tv.tuner.data.nano.Channel;
The build.gradle is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.android.tv"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "libtunertvinput_jni"
}
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/usbtuner-res']
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/exoplayer.jar')
compile project(':common')
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.android.support:support-annotations:+'
}
You can't import these because they have @SystemApi
annotation. You can check this for the source code of TvContentRatingSystemInfo
. I have also checked WatchedPrograms
and it also has @SystemApi
annotation. I have not checked the other three.
You need to be system app to access these. As you can see here, you need to push your app in the the \system\
folder. You can find detailed information about AOSP build system here.
Solution :
Changing your android.jar
to the .jar in this github should enable you to access system API. The reason is your standard android.jar
doesn't have system API. So you need to get framework.jar
(by adb pull
) from emulator and combine it with core.jar
then you can have new android.jar
which contains system API (system methods and classes are available in the framework.jar
from emulator).
Moreover, you should push your apk to \system\priv-app\
folder to access some system API but I don't know why I can access system API without pushing my apk to \system\priv-app\
when I use .jar from that github account.
I feel like I don't write quite clearly but at least now you have more understandings of what you're facing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With