Android Studio gradle errors - android

When i go to :
File > Project Structure
I have the following 5 errors:
Library 'appcompat-v7-19.0.1' is not used
Library 'Gradle: 19.0.1' is not used
Library 'Gradle: support-v4-19.0.1' is not used
Library 'Gradle: 4.2.42' is not used
Library 'play-services-4.2.42' is not used
I can fix the problem with the icon on the right, add to dependencies and i add to the selected module, it works but if i exit Android Studio and i run it again, the errors appears again.

Those errors are spurious and you can ignore them; that they appear at all is bug https://code.google.com/p/android/issues/detail?id=60958. Having said that, unless you're running a very old version of Android Studio, they shouldn't be appearing.

Related

How do I add in a class created in a different android project?

Please forgive the vague sounding title
I am trying to get this project to compile in android studio:
https://proandroiddev.com/how-to-create-a-bubble-selection-animation-on-android-627044da4854
https://github.com/igalata/Bubble-Picker
Downloading the github project and compiling it as it is did not work, I am getting this error, and redownloading dependencies and syncing as suggested in the error message did not work
UPDATE: I have upgraded android studio, gradle and kotlin plugin to latest version and it's still the same problem.
I can use the library version of this project just fine, using the steps described in the github page. I want to compile the source code of this component together with my project so that I can tweak the bubble animation itself. Since the github project itself does not compile, I created a Hello World project first, then manually copied in the bubblepicker folder in the Hello World project. Inside the bubblepicker folder, I changed the name of the folder tree java/com/iglata/bubblepicker to java/com/test/app/bubblepicker, and changed the package name of the files inside this folder to reflect this. I then copied the code in DemoActivity.kt to my MainActivity.kt and changed the package names and made few minor adjustments to make the compiler errors go away.
I have made some modifications in the gradle files as well so that gradle syncing does not give any errors. However, anything inside bubblepicker does not seem to be detected in the MainActivity.kt, or it's activity layout xml file. For example,
import com.test.app.bubblepicker.BubblePickerListener
is marked with red colour in android studio and the error is unresolved reference. If I remove all references to bubblepicker and replace the code in MainActivity.kt with the Hello World code, then it compiles and runs fine, so it's as if bubblepicker is not getting picked up by the compiler at all.
What could be the problem here?
Or at the very least, how can I compile the bubblepicker github project? Simply loading the whole project in Android Studio is giving me compiler errors. I am doing this on Android Studio 3.5 on macOS with Kotlin version latest as of September 4.
I didn't get any error while import Github project.
Kindly update your android studio and kotlin Gradle version and check same.

How to Configure AspectJ in Android Studio

I am trying to configure AspectJ in Android Studio. But after all trial and error its not working ! Surprisingly I am able to make it work with Eclipse Kepler version The steps I followed for Android Studio
Created sample Android Project
File > Settings > searched for AspectJ in Plugin section
Assuming nothing more to be done in Studio , except configuration of build.gradle files
Added compile 'org.aspectj:aspectjrt:1.8.1' to the to the build.gradle (Module:app)
Created Analytics_onBackPressed.aj for back button press detection
Created Analytics_OnClick.aj for click events detection
Created Analytics_onCreate.aj for components oncreate event detection
Created necessary dependency classes which the above mentioned *.aj classes will internally call
Added required permissions in Manifest
Running the project is not detecting any of the events (button click, oncreate or back button click)
Followed these links ReferenceLinkOne , ReferenceLinkTwo and ReferenceLinkThree
My Question is what is more required to make AspectJ working with Android Studio
Steps followed in Eclipse and got AspectJ working
Downloaded Eclipse Kepler version
Through Install New Software option searched for http://download.eclipse.org/tools/ajdt/43/update
Installed AspectJ Development Tools (Required) .
Created sample android project
Created Analytics_onBackPressed.aj for back button press detection
Created Analytics_OnClick.aj for click events detection
Created Analytics_onCreate.aj for components oncreate event detection
Added required permissions in Manifest File
Right clicked in project and converted project to AspectJ by the following
Configured Java build path with AspectJ runtime library
Now while running the project, I am able to detect components oncreate, back button press
Environment Used
Android Studio : 2.1.2
JRE : 1.8.0
Windows 7 Enterprise
Any help is highly appreciated!
EDIT : 1 , From the output , still AspectJ is not properly configured
As per this link , I created jar file from eclipse including *.aj files and corresponding dependency. Excluded AndroidManifest.xml while creating jar file and created jar
Created Project in Android Studio. Placed this *.jar file in libs file. (apps> libs). I have enabled AspectJ waving as shown below
Now searched the properties for AspectJ and enabled
Now running the project, should be creating logs I had put in *.aj files which is in plugin . Unfortunately these logs are not printed in Android Studio logs.
Form which I am concluding still AspectJ is not enabled in this project OR there is a configuration error
Disclosure: I am the author of the inofficial AspectJ weaver plugin.
As noted in the AspectJ weaver plugin documentation, the plugin does not support compiling .aj files.
To use this plugin, you have two options:
Switch from .aj to annotation style aspects.
Compile the .aj files outside the IDE (IntelliJ Community / Android Studio), for example using Maven/Gradle/Ant, and package them into a .jar. Include this .jar as a dependency in your project and click the Search for aspects... button, as per the documentation.
I have had various success trying to get AspectJ working in Android Studio. This link helped me get part of the way there (assumes Gradle build setup for your project). http://fernandocejas.com/2014/08/03/aspect-oriented-programming-in-android/
Using the custom block of code in the build.gradle file, I was able to get aspects defined using annotations in .java files compiling and weaving properly in my project. However, this same method did not work for me when defining native aspects using .aj files. I hope it helps.
IntelliJ has no tooling support for AspectJ, and Annotation Style AspectJ can work on Android studio. Just treat the aspect code as Java code.
For detail read this issue
aspectj for Android studio - where is AJDT plugin
Also, you can use gradle plugin aspectjx which can weave kotlin code and demo is here

App compact v7 error

I am trying to modify my code to include the latest nav drawer as seen in Google play stand. For this the first step is to add the app compact v7 to my project. I first updated my SDK and then imported the library project. It threw some errors, I gooogled and set the version to 21 in Project properties. The errors were resolved.
Now when I try to add this to my project by importing the library I get all sort of resource not found errors. I am clueless as only after adding the app compact v7 to my project as a lib I get these errors what can be possibly wrong here?
I am following steps exactly as defined here
Here is the screen shot without any errors on app compact v7:
Right click on project --> Go to properties --> Go to Android --> Set Project Build Target as Android 5.0 or 5.0.1 --> Apply......Hope this will solve your problem

Problems converting to library project including Facebook SDK

I have a working app that I've now converted to being a library project in Eclipse. When I attempt to include the library as a "Project Reference" in an empty app (no other functionality other than what it inherits from the library) it fails to build. I get the message Unable to execute dex: Multiple dex files define Lcom/facebook/android/R$attr;.
To try to work around this I tried to delete the Android Dependencies completely. But then I get a "Class not found exception" for classes in the library.
Is it possible to remove the Facebook dependency without also removing the app library dependency? I tried to delete the facebooksdk.jar file but was unable to do so since all the buttons are grayed out. (see screen capture below)
I also tried simply unchecking "Android Dependencies" in "Order and Export". That had no effect on the problem.
Your suggestions are welcome.
FYI, my project has 3 main components. All 3 are contained in the same Eclipse project folder (see screen capture):
Application "App_A"
Library_L (included as Project Reference in "A") It's worth noting that Library_L executes perfectly when I run it as a non-library project.
Facebook SDK 3.0.2 (included as Project Reference in Library_L (see screen capture)
Project References are used to include a library project (e.g., the Facebook SDK).
The documentation -- and books by balding guys -- show you how to attach an Android library project to your app, and it has nothing to do with "Project References".
Similarly, the documentation for the Facebook SDK shows you how to attach their Android library project to your app (see Step 6). They follow the standard Android library project approach, and that too does not involve "Project References".
Now, it is conceivable that there's something about a newer Eclipse version (I'm running Indigo) that causes "Project References" to show Android library projects as checked -- it does not do so in my version.
Make sure that you have properly set up the Android library projects, and see if that helps with your issue.

Android Studio - ActionBarSherlock won't let app launch

From Android Studio, I have imported a previous non-Gradle Android project from Eclipse.
It includes ABS and runs in Eclipse without problem.
It compiles error free in Android Studio. However, every single time I run it, it doesn't just run as it does in Eclipse, it goes into some test mode and gives the following output.
Running tests
Test running startedTest running failed: Unable to find instrumentation info for: ComponentInfo{com.my.package/android.test.InstrumentationTestRunner}
Empty test suite.
Then doesn't open up at all.
Try to include word 'test' in your methods I have faced it and have to name all methods like testIfOneIsOne or OneIsOneTest(not sure now what order I used).
Also: Are You use same version of junit on both eclipse/intelij?
try checking my solution here. ABS includes junit which might be running for you. Try following my solution here:
Problems importing project into Android Studio regarding ActionBarSherlock
Below is the detail which will hopefully also work in your case. Specifically check step 4)
The steps below allowed me to get ActionBarSherlock running with no issues.
1) Download latest ABS here: [http://actionbarsherlock.com/][1]
2) Extract ABS you should have a directory in there called "actionbarsherlock". Copy that to your Android Studio workspace. and rename to ActionBarSherlock (changed casing) -- > I now have my Android Studio Projects under \*documents*\Android Workspace\ As opposed to \Eclipse Workspace\
So you should now have something like :
\*documents*\Android Workspace\ActionBarSherlock\
Along with your main project maybe:
\*documents*\Android Workspace\TestProject\
3) Open Android Studio load your TestProject then goto File> Import Module... Now navigate to ActionBarSherlock under \*documents*\Android Workspace\ActionBarSherlock\
Click Ok and next all the way to finish. It will ask if you want to set a dependancy to the new Module (or at least mine did) click OK
4) at this point when compiling I was getting errors in \ActionBarSherlock\test\ complaining about Junit. I simply deleted the \Test\ directory from my ABS Module under project view. Right click \test\ > Delete.... You could also include the junit jar file but I don't think its necessary
5) you should now be able to compile without errors

Categories

Resources