What is the dependency for android.media.tv

I am trying to move an Android TV app to Android Studio. When I tried to compile it, I had some import errors. I could not find the dependency that I can add to build.gradle to solve this problem. Import List:

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; 

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:+' } 
+8
java android android-tv gradle tv
source share
4 answers

You cannot import them because they have the @SystemApi annotation. You can check this for the TvContentRatingSystemInfo source code. I also checked WatchedPrograms and it also has @SystemApi annotation. I did not check the other three.

You must be a system application to access them. As you can see here , you need to put your application in the \system\ folder. You can find detailed information about the AOSP build system here .

Solution: changing your android.jar to .jar in this github should allow you to access the system API. The reason is because your standard android.jar does not have a system API. Therefore, you need to get framework.jar (by adb pull ) from the emulator and combine it with core.jar then you can have a new android.jar which contains the system API (system methods and classes are available in framework.jar from the emulator).

Moreover, you must \system\priv-app\ your apk to the \system\priv-app\ folder to access some system API, but I don’t know why I can access the system API without pressing my apk in \system\priv-app\ when I use .jar from this github account.

It seems to me that I am not writing very clearly, but at least now you have more understanding of what you are facing.

+1
source share

android.media.tv and com.android.tv are part of the Android SDK. Therefore, you do not need to include additional libraries in the gradle.build file.

Just make sure:

Update your SDK tools to version 24.0.0 or higher

and

Update SDK with Android 5.0 (API 21) or higher

Example

  android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.example.tvapp" minSdkVersion 15 targetSdkVersion 26 versionCode 1 versionName "1.0" } } 
0
source share

use this in your dependencies "com.android.support:support-media-compat:26.0.2"

and also use the version of the tool "26.0.1"

compiled SDK version 26.

0
source share

You can add gradle application level dependencies.

 compile 'com.google.android.libraries.tv:companionlibrary:0.1' 
0
source share

All Articles