Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is a dependency for android.media.tv

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:+'
}
like image 782
MRM Avatar asked Aug 30 '17 14:08

MRM


1 Answers

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.

like image 66
Yonathan Randyanto Avatar answered Oct 01 '22 22:10

Yonathan Randyanto