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.
android.media.tv and com.android.tv are part of Android SDK. So you don't need to include any additional libraries in gradle.build file.
Just make sure to:
Update your SDK tools to version 24.0.0 or higher
and
Update your 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"
}
}
use this in your dependencies "com.android.support:support-media-compat:26.0.2"
and also use tool version "26.0.1"
compiled SDK version 26.
You can add dependencies in app level gradle.
compile 'com.google.android.libraries.tv:companionlibrary:0.1'
Related
While learning about RecyclerView, I am facing some problem. GreenAdapter Class failed to import “android.support.v7.widget.RecyclerView”. I am using Android Studio 3.1.4. My compile SDK Version is 28. Here's my build.gradle File:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.sunshine.sunshine.app"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':sunshinemodule')
implementation project(':base')
implementation 'com.android.support:design:28.0.0-rc01'
}
I am also sharing the code where the import is not working:
You should add
implementation 'com.android.support:recyclerview-v7:27.1.1' //28.0.0-rc01
After that, Clean-rebuild and Run.
Add this to your gradle:
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
and then click "Sync now".
Right click on app --> Open Module Settings --> Dependencies then on right side click on plus button. Add library dependency and search recyclerview and then add it.
I build a player based VLC,and when I want to build a verson for Android 6.0,player can't start on Android 6.0 device.Here are the log:Can't load vlcjni library:java.lang.UnsatisfiedLinkError:dlopen failed:/data/app/lib/arm/libvlcjni.so: has text relocations.
And I have tried so many ways to solve it,but I haven't solve it yet.
I hope anyone can tell me about the problem.
Here is similar question and answers: libavcodec.so: has text relocations
Today, I got the same error messages when testing my app with Android 6.0 on a Nexus 6 (Motorola). I solved my issue by checking the targetSDKVersion in the manifest file. Using "22" and not "23" as targetSDKVersion solved it. (See below)
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="22" />
I also checked the build.gradle files for compile version and targetSDKversion:
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
Hope this will help you. However, this is just a short term workaround for now, I hope that we will get some feedback from metaio though.
Regards, christin
I only had to create a libs folder in my Android library, and then move the library files from the jniLibs folder to the libs folder. I believe this may have to do with the newer version of Gradle and build tools. That way, you don't have to downgrade your build tools/Gradle.
UPDATE:
I was able to build with the following build.gradle script for vlc-android. I needed the following updated versions. This allows me to build with SDK version 24, with build tools 24, and gradle version 2.2.0. See if this works for you.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'org.ajoberstar:gradle-git:1.3.2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//noinspection GradleCompatible
compile "com.android.support:support-v4:25.2.0"
compile 'com.android.support:support-annotations:25.2.0'
}
I am just starting to learn android and i just installed android studio on windows 10 pc. And the very first problem that I am facing is "can not resolve the symbol "AppCompatActivity". Here is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "quikkhome.com.myapplication"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
}
there is problem
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
you are added 2 time
compile 'com.android.support:appcompat-v7:23.1.0'
remove one time may be its help you
I just fixed the problem (though I do not know how did it work). I just changed the API from 21 to 23 and then back to 21. It is working perfectly now.
Try looking at your xml layout files, make sure all are targeting the same API. Change them to what ever you are targeting if different, like API 23 for example. The latest API may not be working yet, like N preview for example. This can be done by clicking the 'design' tab at the bottom if you are looking at an xml layout. Look for the little android man with the number beside it, click it.
Now also make sure the same theme is selected for all layout files. For example you may be using AppTheme as the theme.
Last run 'clean project'. At the top click Build, in the drop down menu click Clean Project.
I have a problem with my Android project. It can't be build because of this error: error: cannot find symbol class LocationClient. I already red that you need to use a lower version of google play services like 'com.google.android.gms:play-services:5.+'.
But when I use that one I get another error: Error:Attribute "theme" has already been defined. And when I googled that one it said that I need to use a higher version of google play services like 'com.google.android.gms:play-services:6.+'.
So I need to use both version 5.+ and 6.+ but that is not possible. Are there any solutions for this problem?
This is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "app_id"
minSdkVersion 19
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//tried different versions of the librarys, without success
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.android.gms:play-services:5.+'
}
The best thing that I could do is replace the LocationClient with the GoogleApiClient. Because LocationClient is deprecated. The replacement class is the GoogleApiClient. It has similar functions so its easy to replace.
Documententation: https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.html
I have been developing this android for some days now, and suddenly the application build has a lot of errors and doesn't run. First few errors are listed below
D:\somepath\someotherpath\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\values-v11\values.xml
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
A couple of things might have caused these errrors are listed below
I was attempting to speed up the Emulator by using Intel HAXM, and also use Genymotion. I can see changes in the dependencies of the build.gradle
build.gradle old
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.nirvanasoftware.donor_app"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
}
**build.gradle New **
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.nirvanasoftware.donor_app"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Is the change in dependency causing build errors or something else.
In the dependencies you have used appcompat-v7:21.0.3 and support-v4:21.0.3
But your compileSdkVersion is 20 buildToolsVersion is "20.0.0"
As I know if you use compileSdkVersion 20 then you should use buildToolsVersion "20.0.0" and the version of support library should also be 20 not 21. If you want to use appcompat-v7:21.0.3' and support-v4:21.0.3' you must use compileSdkVersion 21 and buildToolsVersion 21.x.y (here x and y will be the number according to your build tools that you have installed on your computer)
I am not sure that all of your problems are caused for this. But if there is a problem in your gradle synchronization then suddenly you will have a lot of problems. So if you do not have errors other than your gradle build file then your problems should be removed.
My suggestion is if you want to use latest SDKs and Support libraries install the latest build tools and SDKs from the Android SDK Manager then use
compileSdkVersion 21
buildToolsVersion "21.1.2" // your latest build tools
and dependencies like this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Hope it will solve your problems. Happy coding :D
In addition: In the latest gradle version that is gradle-1.0.0 runProguard is a deprecated method. So instead of using it you must use minifyEnabled and update your gradle version to 1.0.0.