I followed the instructions at this link to create a simple mobile/wearable app in Android Studio. However, it won't recognize any of the classes specific to the wearable SDK, giving the error "cannot resolve symbol ______". The screenshot at this link is what I am seeing.
The following is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.example.lsykora.androidwearwidget'
minSdkVersion 'L'
targetSdkVersion 'L'
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'
}
}
productFlavors {}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v13:+'
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}
I have installed all SDK's using SDK manager and I have tried tinkering with the minimum, target, and compile SDK's in the build.gradle file, setting them to 19, 20, or Android-L, but I'm having the same results - program won't compile because of these unrecognized classes. Any input is appreciated! Thanks
Don't extend WatchActivity (that class doesn't actually exist).
The base class for Android Wear activities is just the standard Activity.
(Also, if you're using Android Studio 0.8.0, update to 0.8.1 -- 0.8.0 has a bug in its templates and creates new Activities using extend WatchActivity, which is actually invalid).
Related
I am new to android things. Recently I tried to build an android things app on android studio 2.3.3 with 25 SDK.
But when I include the android things support library into the dependency of app module build.gradle file and sync with latest gradle changes,it gives me the below error :
"Install repository then Sync"
Plz Someone help me.
You don't need to connect Raspberry Pi to develop a Android Things project.
There are three points which you have to keep in mind while developing for Android Things:
Update your SDK tools to version 25.0.3 or higher.
Update your SDK with Android 8.0 (API 26) or higher.
In order to access new APIs for Things, you must create a project or modify an existing project that targets Android 8.0 (API level 26) or higher.
Add the library.
In your case, you need to install the latest bulid tools, and repositories to develop an Android Things Project.
Your build.gradle should look like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.android.androidthings.id"
minSdkVersion 21
targetSdkVersion 26
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:25.3.1'
provided 'com.google.android.things:androidthings:0.3-devpreview'
}
In my Android studio I am only able to see the support libraries for the version 25.0.0 but my compile SDK version is 23 when I try to add com.android.support:recyclerview-v7:23.0.4 I get an error message that
Error:(27, 13) Failed to resolve: com.android.support:recyclerview-v7:23.0.4
but as per the SDK manager it shows that I have installed all the support libraries.
On top of that I am unable to locate the v7:23.0.4 libraries in the menu
File => Project Structure => Dependencies
Here are the screenshots
My Questions
Why am I unable to see the support libraries for the version v7:23.0.4 ?
If the support library is not installed how come it does not show in my SDK Manager ?
EDIT 1
Build.gradle(Module.app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "appnotic.quicknotes"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.2'
}
EDIT 2
1) it is not available from the repository, why? I don't know, but it is not the latest one for version 23, try com.android.support:recyclerview-v7:23.2.1 instead
2) you don't install the libraries with the SDK manager, that only install the source where gradle get the library from, the library itself gets downloaded when you build
I tried with 23.0.4 and could not get it, with 23.2.1 yes. If you can get version 25.0.0 it means that the repository is installed, maybe the gradle project is messed up somehow. Try to delete the project iml file and .idea folder and recreate it.
I am trying to build an app which is composed out of separate library projects.
To do this, I'm trying to make a proof of concept which is supposed to be as following:
I tried to keep the project as simple as possible. The projects contents do not matter!
All that matters is the dependencies between the projects!
The result should be that MainProject will print out Something Another String!
I have tried all from .JAR files to .AAR files, but the best I got was
with the dependency in red. I added the StringExtender.aar file to StringReturner, and then the StringReturner.aar file to the MainProject.
When I do this I get the following Exception:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/erik/stringextender/StringExtender;
What is the right way to setup a simple proof of concept like this? I can't seem to find anything related to a library project having a dependency. It's all 1 level deep!
Any help is welcome!
EDIT SHOWING GRADLE BUILD FILES
StringReturner:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile project(':StringExtender-lib-debug')
}
MainProject:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.erik.erikpoc10"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile project(':StringReturnerLib-debug')
}
Use the following tutorial - Creating libraries for Android applications
See a working example project on my Github
The most important steps taken were:
8.3. Create library module.
8.6. Define dependency to the library project.
Do not forget to import the library class you want to use, for example:
In MainProject: import com.example.stringreturner.StringReturner.
In StringReturner: import com.example.stringreturner.StringExtender.
The info below is based on the image you provided:
The library methods are not static so don't forget to make an actual object.
So StringReturner should make a StringExtender object, And MainProject should make a StringReturner object first!
And finally, I think it's a typo but both libraries have the class StringReturner. This will not work in the StringReturner library for obvious reasons.
I should also note that I used Android Studio 2.0 and I did not touch .JAR files nor .AAR files. I merely created two library modules and one app. Then configured the Project Structure -> Dependencies by adding Module Dependencies.
We are moving our years old Android project to Android Studio and away from eclipse.
The problem is that we have some jar files that use code specific to the devices that we work on. (I know! Don't say it. I'm working with the whole team to move past this.) Since these JAR files override some of the bluetooth code, they have to go ahead of the SDK in the dependency list for the thing to build. (These libraries are for compile time only.)
While on eclipse, Android SDK was a full blown plugin and I could control the libraries absolutely and make sure these libraries were first. With Android Studio, I don't seem to be able to control the position of the SDK in the dependency path.
I have edited the app.iml file and changed the order of the orderEntry tags at the bottom. This appears to have fixed the problem inside the IDE and it appears to be building fine now.
I am still unable to build the project using gradle.
Based on feedback here, here is my current build.gradle
apply plugin: 'com.android.application'
configurations { razrBuild }
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
razrBuild fileTree(dir:'assets',include: ['*.jar'])
provided files('assets/BluetoothGattService.jar')
provided files('assets/BluetoothGatt.jar')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('libs/android-support-v4.jar')
compile files('libs/myapp-util.jar')
}
project.afterEvaluate {
project.android.applicationVariants.all { v ->
v.javaCompile.classpath += configurations.razrBuild
}
}
Any ideas?
Put jars you want to compile time only into a folder(For my example : extlib)
Then add some configurations to build.gradle
configurations { providedCompile }
dependencies {
providedCompile fileTree(dir:'extlib',include:['*.jar'])
}
project.afterEvaluate {
project.android.applicationVariants.all { v ->
v.javaCompile.classpath += configurations.providedCompile
}
}
I imported a project into Android Studio from Eclipse. It was building successfully in Eclipse.
At the end of importing process I got this error:
Gradle project sync failed. Basic functionality will not work
In the Gradle console I get the following error:
Error:Failed to find: com.android.support:appcompat-v7:20.+
I have already installed google support repository as mentioned in other places.
This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.0.0"
defaultConfig {
applicationId "com.entujn.demo"
minSdkVersion 10
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:20.+'
compile files('libs/commons-lang3-3.3.2.jar')
}
local.properties:
sdk.dir=/home/pankaj/adt-bundle-linux-x86_64-20140702/sdk
SDK directory structure screenshot
Looks like the appcompat stuff is not present at the right place, how do I fix it ?
Looks like Android Studio uses another copy of SDK, which does not have Android Support repository installed. Please make sure it has all needed components installed.