Dagger 2 : Cannot resolve symbol for dagger component - android

I would like to exercise this Dagger 2 Vehicle Motor example.
I made everything exact like in that tutorial, except for my gradel.build:
compile 'com.google.dagger:dagger:2.4'
apt 'com.google.dagger:dagger-compiler:2.4'
compile 'javax.annotation:javax.annotation-api:1.2'
but then I get an
error: cannot find symbol variable Dagger_VehicleComponent
Whats wrong there? (Same without '_' underscore)

Another version solved it:
compile 'com.google.dagger:dagger:2.2'
apt 'com.google.dagger:dagger-compiler:2.2'
provided 'javax.annotation:jsr250-api:1.0'

Change Dagger_VehicleComponent with DaggerVehicleComponent
Clean and rebuild your project
Import DaggerVehicleComponent class

Took me a while to figure this out. But I found the reason (At least on my side)
I created a project from scratch, after that I was trying to set up the basic components/tools till I bump into this issue.
Reading other answers I found that DaggerApplicationComponent class is autogenerated by the compiler, then I thought, why the IDE can't "find" this class?
The answer is obvious and... you got it, was because the project wasn't compiling, here are the steps to solve this issue if the scenario is the same as mine.
1) Open terminal and go to your projects path (Or simply open the terminal in the Android Studio)
2) Clean project
./gradlew clean
3) Build the project
./gradlew build
NOTE: If by this point you have noticed the project is not compiling... Bingo! That might be the real issue. Then follow the next steps:
4)Open gradle and add the buildToolsVersion '23.0.1' and very IMPORTANT has to be enabled multiDexEnabled true
This is how my gradle in the app module looks like
android {
buildToolsVersion '23.0.1' // IMPORTANT
compileSdkVersion 26
defaultConfig {
applicationId "com.fixing.dagger"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true // ALSO IMPORTANT
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
After that you will be able to import the DaggerApplicationComponent.
Hope this saves time for someone else!

Related

How to fix ERROR: No signature of method: build_ap86oam3dut3pxce3x49rdtma.android()?

ERROR: No signature of method: build_ap86oam3dut3pxce3x49rdtma.android() is applicable for argument types: (build_ap86oam3dut3pxce3x49rdtma$_run_closure1) values: [build_ap86oam3dut3pxce3x49rdtma$_run_closure1#47588b04]
The build gradle is:
apply plugin: 'com.android.application'
android{
implementationSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.uiresource.taksiku"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.3-alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "com.android.support:appcompat-v7:$var"
implementation 'com.android.support:design:28.0.0'
testimplementation 'junit:junit:4.13'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta5'
implementation 'de.hdodenhof:circleimageview:3.1.0'
}
If you are using kotlin version 1.4.21 or newer, kotlin-android-extension is deprecated.
So if you removing the plugin you also have to remove the android experimental extension block.
In my case, I had to remove these pieces of code.
apply plugin: 'kotlin-android-extensions'
androidExtensions {
experimental = true
}
But if above did not fix it
This a kind of general and/or wrapping error which hides the real cause and/or problem, hence to see actual error message, try something like:
./gradlew :app:assembleDebug --stacktrace
And search for resulting real error-message instead.
I had the same error message until I commented out everything in the android plugin except the compile sdk version, trying to get back to a successful build config.
android {
compileSdkVersion 23
/*
...
*/
}
Then, I started uncommenting things until I narrowed the problem down to using the following incorrectly.
ProductFlavors {
...
}
I'm not sure if you're using the same block, but at the moment, I'm leaving it commented out because I'm not sure it's needed. Once I got rid of it though, I was receiving other errors about sdk root dir location, so I was able to fix those.
I hope this helps!
I was getting a similar error because the versionCode was being taken from a properties file, but the versionCode needs to be an integer and not a string, so toInteger() was needed.
Nice logs, android.
Best thing you can do is comment parts of your build.gradle file related to the issue until you get a good build and them uncomment 1 by 1 until you find the problem. I had the same error and it was related with a typo in one of the app build.gradle blocks. I was using:
android {
...
buildFeature {
...
}
}
instead of
android {
...
buildFeatures {
...
}
}
Good luck!
This is a syntax error somewhere in your gradle file inside the android {} closure. If you are someone having this same problem then the best solution to this problem is to comment out portions of code inside android {} and keep running gradle sync until you have a successful build. Then slowly add back commented out lines until you find the culprit.
in my case I needed to comment out this lines in gradle
androidExtensions{
experimental = true
}
This issue is usually related to some change on build.gradle file, for example in my case, was this line in the defaultConfig section on that file:
versionCode 1.1
I changed it to:
versionCode 2
and problem fixed.
I removed this code from my Gradle:
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
In Android Studio 2021.1.1 Canary 12, I removed
plugins{
...
id 'kotlin-android-extensions'
}
But forgot to remove this from
android{
androidExtensions {
experimental = true
}
}
after removing androidExtension block my problem solved
I was checking a very old project from Github and found the solution by matching the app level build.gradle file with my current project, hence the solution is to replace
runProguard false
with
minifyEnabled false
It must've been deprecated and removed in a later build which caused a similar issue - No signature of method: build_6f958jjxpxn7lllu9wu5brezx.android()
There's no unique solution for this error, except that it's a syntax error inside build.gradle file.
I'm using JAVA, but for some reason Android Studio added kotlinOptions into android block without my knowledge. And then the same error happened. I put here just in case someone need it.
android {
// ...
// remove this block if you are using Java
kotlinOptions {
jvmTarget = '1.8'
}
// ...
}
It is because there's syntax error in android{..} part of build.gradle
You've used implementationSdkVersion which should ideally be compileSdkVersion. Error in variable names in android{..} leads to such errors.
TLDR;
Replace implementationSdkVersion with compileSdkVersion
I just removed useProguard true in build.gradle > android > buildTypes, and it worked for me.
i was trying to add parcelable plugin in my project. this was the same error in my case too. Because, JetBrains extracted the Parcelize from Kotlin Android Extensions to a new plugin, kotlin-parcelize
So, If you want to add easy parcelable in kotlin then follow these steps:
First you will need to add kotlin-parcelize plugin to your module
plugins {
..
id 'kotlin-parcelize'
}
Then change your old import statement from
import kotlinx.android.parcel.Parcelize
to
import kotlinx.parcelize.Parcelize
Example:
import kotlinx.parcelize.Parcelize
import android.os.Parcelable
#Parcelize
class User(
val name: String,
val age: Int
): Parcelable
I'm new to Android but i got a message similar to yours today when i try to use a different version (not the suggested ones) of the Gradle plugin and gradle engine on Android Studio 4.1 canary.
When I had on my App build.gradle these lines:
task wrapper(type: Wrapper){
gradleVersion = '5.6.4'
}
and on my build.gradle for the module this line
classpath 'com.android.tools.build:gradle:3.6.3'
This was the message i got with previous settings:
A problem occurred evaluating project ':app'.
> No signature of method: build_5dcjpn4h9nkpym0yszxs5w2uh.android() is applicable for argument types: (build_5dcjpn4h9nkpym0yszxs5w2uh$_run_closure1) values: [build_5dcjpn4h9nkpym0yszxs5w2uh$_run_closure1#2e4515b3]
The way i found to solve this error was changing version for the gradle plugin on my build.gradle for the module like this
classpath 'com.android.tools.build:gradle:4.0.0'
I hope this could help you.
Happy coding!
For me I had updated firebase-crashlytics-gradle from 2.5.2 to 2.7.1 in my project build.gradle and that caused the issue.
dependencies {
[...]
classpath "com.google.firebase:firebase-crashlytics-gradle:2.7.1
}
I removed an unnecessary firebaseCrashlytics configuration in my app module build.grade and then it worked again:
// TODO this entire block had to be deleted to fix the issue
firebaseCrashlytics {
mappingFileUploadEnabled = false
}
This problem is common in Flutter 2.8
Delete Folder with all sub Folder of C:\Users\LENOVO\.gradle
Go File menu > Setting (Ctrl+Alt+S)
Go Appearance & Behaviour > System Setting > Android SDK > SDK Tool Tab
and then uncheck Android SDK Build-Tool press OK Button
3)Run Project (Shift+F10) in Andriod Studio it will Download all required files from the internet and your issue resolve
After if the issue is Not resolved then Second Step is:
Go > android\app\build.gradle in your project
Please Add > minSdkVersion 19 or 20
// Remove it because, 16 is by default minSdkVersion in flutter 2.8
//minSdkVersion flutter.minSdkVersion
add multiDexEnabled true if file size increase from limits
I added debug under buildTypes in the gradle file and missed a comma after "API_URL":
not working:
buildTypes {
...
debug {
buildConfigField "String", "API_URL" "\"http://myapi.com/\""
}
}
working:
buildTypes {
...
debug {
buildConfigField "String", "API_URL", "\"http://myapi.com/\""
}
}
good luck!
For me, the problem was in this block
defaultConfig {
applicationId "abc"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 12.1 **-> 13**
versionName "3"
}
The 'versionCode' mustn't be a decimal number
I had a problem similar to #LalitFauzdar 's but with a different solution. A plugin that I'm using requires custom ProGuard rules for release builds, but adding a reference to the rules file in the app gradle file resulted in the error in question. Here is the offending line, commented-out:
buildTypes {
release {
signingConfig signingConfigs.release
// proguardFiles 'proguard-rules.pro'
}
}
I had this error when i added 2 product flavors to my build.gradle app module file with the following names:
productFlavors {
normal-sv1 {
...
}
normal-sv2 {
...
}
}
Found out that this error was because of the '-' int the middle of the flavors' names.
When i used '_' instead of '-', like below, the error was gone.
productFlavors {
normal_sv1 {
...
}
normal_sv2 {
...
}
}
I received this error while creating a new Jetpack Compose project. 'app' module's build.gradle was cracking up.
Removing packagingOptions did the trick for me ->
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
There is no general answer to this problem. There is just something wrong with the app/build.gradle.
In my case I defined a variable named versionCode which caused the error. Renaming it to e.g. versionCode_ fixed the problem.
Make sure you are using the kotlin android plugin instead of the kotlin jvm plugin.
apply plugin: 'kotlin-android' // NOT kotlin-jvm
I had a similar issue because I had added a trailing comma , in defaultConfig in android/app/build.gradle
Try to comment this in your app level build.gradle file
openOptions {
disable 'InvalidPackage'
}
Thanks for mentioning to just comment things and test, for me it was:
kapt {
useBuildCache = true
}
Removed it, everything was building again.
Happened after updating Kotlin version.
Old issue but worth noting you might need to follow the migration guide here if you see this issue:
https://developer.android.com/topic/libraries/view-binding/migration
For me, removing the line apply plugin: 'kotlin-android-extensions' and adding view binding as below resolved the issue:
buildFeatures {
viewBinding true
}
I got this problem after adding
kapt {
// etc
}
because I hadn't added:
apply plugin: 'kotlin-kapt'

Android Studio 3.0 Execution failed for task: unable to merge dex

android studio was getting build error while build execution with following:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex"
My app:build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.pdroid.foodieschoice"
minSdkVersion 16
targetSdkVersion 25
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(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
testCompile 'junit:junit:4.12'
}
configurations.all {
resolutionStrategy {
force 'com.android.support:appcompat-v7:26.0.1'
force 'com.android.support:support-compat:26.0.1'
force 'com.android.support:support-core-ui:26.0.1'
force 'com.android.support:support-annotations:26.0.1'
force 'com.android.support:recyclerview-v7:26.0.1'
}
}
apply plugin: 'com.google.gms.google-services'
any solutions
Edit: i have done with sample through firebase github site and solved
For Cordova based project, run cordova clean android before build again, as #mkimmet suggested.
This error happens when you add an external library which may not be compatible with your compileSdkVersion .
Be careful when you are adding an external library.
I spent 2 days on this problem and finally it got solved following these steps.
Make sure all your support libraries are same as compileSdkVersion of your build.gradle(Module:app) in my case it is 26.
In your defaultConfig category type multiDexEnabled true. This is the important part.
Go to File | Settings | Build, Execution, Deployment | Instant Run and try to Enable/Disable Instant Run to hot swap... and click okay
Sync Your project.
Lastly, Go to Build | click on Rebuild Project.
Note: Rebuild Project first cleans and then builds the project.
Try to add this in gradle
android {
defaultConfig {
multiDexEnabled true
}
}
Resolution:
Refer to this link: As there are various options to shut the warning off depending on the minSdkVersion, it is set below 20:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
... }
dependencies { compile 'com.android.support:multidex:1.0.3' }
If you have a minSdkVersion greater than 20 in your build.gradle set use the following to shut down the warning:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
... }
Update dependencies as follows:
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Again the only difference is the keywords in dependencies:
minSdkVersion below 20: use compile
minSdkVersion above 20: use implementation
I hope this was helpful, please upvote if it solved your issue, Thank you for your time.
Also for more info, on why this occurs, please read the first paragraph in the link, it will explain thoroughly why? and what does this warning mean.
Simply try doing a "Build -> Clean Project". That solved the problem for me.
For me, adding
multiDexEnabled true
and
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
into the app level Build.gradle file solved the issue
Go to your module level build.gradle file and add the following lines to the code
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
That solved the problem easily. Check this documentation
Use multiDexEnabled true as below.
{
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
and
implementation 'com.android.support:multidex:1.0.3'
this Solution worked for me.
I tried many solutions as mentioned above including the multiDexEnabled true but none of that worked for me.
Here is the solution which worked for me - copy this code in app\build.gradle file
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
Make sure to run gradlew clean before running the code
Same thing happened to me, figured out that I was in the middle of updating to AS 3.0.1 and after I did the update, cleaned and rebuilt the app, everything was fixed.
For me what fixed this error was changing one line in my app's gradle dependencies.
from this:
compile('com.google.android.gms:play-services-gcm:+') {
force = true
}
To this:
compile('com.google.android.gms:play-services-gcm:11.8.0') {
force = true
}
Also be sure your app is subclassing MultiDexApplication
import android.support.multidex.MultiDexApplication
class App : MultiDexApplication()
or if not subclassing Application class, add to AndroidManifest.xml
<application
android:name="android.support.multidex.MultiDexApplication"
This is what works for me. clean prepare and run.
cordova clean android;
ionic cordova prepare andriod;
ionic cordova run andriod;
hope it helps.
I also got the similar error.
Problem :
Solution :
Main root cause for this issue ismultiDex is not enabled.
So in the Project/android/app/build.gradle, enable the multiDex
For further information refer the documentation: https://developer.android.com/studio/build/multidex#mdex-gradle
Are you in between SDK or platform updates?
If yes complete those completely and then try to continue.
I normally update the individual packages that need to be updated as to taking the entire update which could go up to 2.5 GB sometimes. Doing this complete update sometimes fails. I had a number of SDK updates once I upgraded to Android Studio 3.0 and was getting the above error since all packages had not been updated. Once I updated all packages the above error was gone.
In my case changing firebase library version from 2.6.0 to 2.4.2 fixed the issue
For me, the problem was the use of Java 1.8 in a module, but not in the app module. I added this to the app build gradle and worked:
android{
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Same problem. I have enabled multidex:
defaultConfig {
applicationId "xxx.xxx.xxxx"
minSdkVersion 24
targetSdkVersion 26
multiDexEnabled true
I have cleared cache, ran gradle clean, rebuild, make, tried to make sure no conflicts in imported libraries (Removed all transitive dependencies) and made all updates. Still:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Turns out the build did not like:
implementation 'org.slf4j:slf4j-android:1.7.21'
When the version of Android Studio is 3.0.1, Gradle Version is 4.1 and Android PluginVersion is 3.0.0, it will encounter this problem. Then I downgrade Gradle Version is 3.3, Android Android is zero, there is no such problem.
I had this when requested SDK version didn't match the dependencies. You can click the line highlighted and fix this clicking the red light bulb. No need to find the actual version, just let the IDE figure it out for you. And add google repo to maven config.
I was receiving the same error and in my case, the error was resolved when I fixed a build error which was associated with a different build variant than the one I was currently building.
I was building the build variant I was looking at just fine with no errors, but attempting to debug caused a app:transformDexArchiveWithExternalLibsDexMergerForDebug error. Once I switched to build the other build variant, I caught my error in the build process and fixed it. This seemed to resolve my app:transformDexArchiveWithExternalLibsDexMergerForDebug issue for all build variants.
Note that this error wasn't within the referenced external module but within a distinct source set of a build variant which referenced an external module. Hope that's helpful to someone who may be seeing the same case as me!
I Have Done and fixed this issue by just doing this jobs in my code
Open ->build.gradle
Change value
from
compile 'com.google.code.gson:gson:2.6.1'
to
compile 'com.google.code.gson:gson:2.8.2'
1)Please add multiDexEnabled true
2)if you get compilation error then check your app level build.gradle weather same dependencies are implemented with different versions.
3)Remove one if you find same dependencies.
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
hope it works fine :) Happy Coding
The easiest way to avoid suck kind of error is:
-Change library combilesdkversion as same as your app compilesdkversion
-Change library's supportLibrary version as same as your build.gradle(app)

Using data-binding in android error: package *.*.databinding does not exist

I'm trying to implement data-binding in android app. This is the link I'm following to set it up. Even after doing all the necessary implements, I'm getting the following error in gradle-build:
error: package com.example.satpracticeapp.databinding does not exist.
(This package is what I'm importing in my MainActivity.java file)
I tried this (the data-binding compiler), but it didn't work.
The problem is I've already successfully tried a hello-world app using data-binding and it works. But, when I try to implement it in an app I made a few weeks ago, I get the error I mentioned above. Searching for the solutions, I copy-pasted the gradle files from my successful hello world app to my old app - that too didn't work out.
Here is my app level build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.satpracticeapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.0'
}
And here's the buildscript of the project level build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
Here are the links to the minimal version of the three files (if it's needed)
MainActivity.java
ViewModel.java
activity_main.xml
After much hair-pulling, I couldn't figure out the solution and getting the same build error again and again.
So, as a temporary solution, I'm trying to copy-paste my classes and layouts in the working hello world project. What am I missing?
EDIT:
After a few hours of pointless searching, I went back to my code. Checked it word by word and found a typing mistake at the name of a binding variable in the xml file.
Everything works fine now!
I had the same issue, turned out to be a duplicate symbol declaration in one of my *.java classes. It's shown in the Gradle console but it was kinda hidden among the databinding errors. i had about 72 data binding errors and this duplicate symbol error was in the middle so it's easy to miss.

RenderScript BCC Compiler failed while running BasicRenderScriptSample

I have seen the question already asked in Can't find ScriptC_saturation in BasicRenderScript Sample
but as I am new in RenderScript, I can make it out they have already done much, so I cannot find the question as low level as I am asking:
I am using Eclipse Juno and have imported the BasicRenderScriptSample.
I am using the android.support.v8.renderscript (
(eclipse) project properties:
renderscript.target=18
renderscript.support.mode=true
sdk.buildtools=19.0.3
When I was not sure why the ScriptC_saturation is not auto generated, I was stuck till I followed the answer below, and copied the .rc file in the necessary folder, and everything compiled well.
Update:
Setup the necessary gradle properties as below (using jcenter rather than mavencentral):
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.android.basicrenderscript"
minSdkVersion 'L'
targetSdkVersion 'L'
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:18.0.+"
}
On Compilation I get this error in emulator and device all alike (from eclipse as well):
RenderScript﹕ bcc compiler terminated unexpectedly
RenderScript﹕ bcc: FAILS to prepare executable for 'saturation'
What could be the reason?
update 2: My Eclipse version of this project, somehow ran after series of cleaning, on the device (less than L) properly, but Gradle version project runs with THE error everywhere.
Don't put the .rs file in your res/ folders. It is a source file, not a resource. It dynamically creates .bc files which do end up automatically in your res/raw folder.

Android Studio can't find imported library

I've imported a library in Android studio (0.5.3)
My settings.graddle looks like this:
include ':app', ':libs:Android-PullToRefresh-master'
And my build.graddle looks like this:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:support-v4:19.+'
compile 'com.google.android.gms:play-services:4.2.42'
compile fileTree(dir: 'libs', include: ['*.jar'])
project(':libs:Android-PullToRefresh-master');
}
The folder I've downloaded is placed in the libs folder directly under the app folder. Also the graddle syncs and building doesn't provide any error. Yet whenever I try to import import com.handmark.xxxxxx; I get the error cannot resolve symbol 'handmark'. I've chcecked to project structure and the app has the dependency in the list.
What is going wrong and how can I fix this?
I ran into the same issue here and asked the question on the "Android Developer Tools" Google+'s community. Alex Ruiz picked up the conversation and told me:
I'm able to reproduce this issue. Unfortunately, no updates yet. We
are currently fixing the "Project Structure" (the core
infrastructure,) and we will get to this, hopefully soon.
So they are aware of it but we still have to wait until they fix it.
In the root of your project, run :
./gradlew clean && ./gradlew build
Then recompile your project in studio and you should see your new lib.
I had the exact same problem as this, however the library file was an aar file, and it happened a long time after adding the library and developing with it for a while.
Building on the information Thomas provided; I found to fix this you should replace the file dependency with a maven dependency if possible. A good resource for finding and creating your Gradle dependency is Gradle, please.
That site returns the below dependency when searching for PullToRefresh
dependencies {
compile 'com.loopeer.android.thirdparty.pulltorefresh:Android-PullToRefresh:2.1.1'
}

Categories

Resources