Change Arr file then include it in Android Studio - java

I got some arr file that I need to change. It is https://github.com/BlinkID/blinkid-android library and I need to change something in xml file (values directory) to make it work and include it in my project in Android Studio. This is what I did ( I tryed other ways too but without success):
Changed arr extension to zip
extracted it with WinRAR
made changes to xml
Packaged it again and changed to arr extension again
In android studio I went File->New->New module->Import JAR/ARR Package.
If it is not added automatically I would add compile(:LibBlinkId) to gradle
Unfortunatelly when I start typing com.microblink... I don't get intellisense, meaning that library was not added. Also I tryed to rename it to .jar file, then added it to libs directory and go to : File->Project Structure-> selected my app module and added that jar, then in gradle I put something like compile files('libs/LibBlinkID.jar')
That did not help also.

After changing your build.gradle you should also do a Sync Project with Gradle Files.
If there were no errors during this step, I see no reason why your method wouldn't work except for the fact that on step 6 it should be:
dependencies {
compile project(':LibBlinkId')
...
}
If Android studio somehow failed to sync up to your dependencies you might want to try an Invalidate Caches / Restart from the File menu and follow that with a project rebuild.
Update:
If that still does not work but the project builds successfully, try to manually import a known class from the AAR and to use that class in a small piece of code. Then run your app.
When dependency import failures happened to me, after such a manual step Android Studio autocomplete would start to work and give me the correct suggestions.

Related

Android studio can't edit library

I downloaded this library and i extracted the rar into my app\libs folder.
Then I added compile 'com.github.lzyzsd:circleprogress:1.1.0#aar' to my build gradle as it says, and clicked on sync.
Then I noticed that the max is set to 100 (in file DonutProgress.java).
I changed it to 5, clicked on sync again but nothing changed.
After few hours of trying I decided to completely remove the extracted folder from my app\libs and sync again to see what happens.
Surprisingly, everything was still working like library was still there.
Can someone explain me what's happening here, I have to edit it but it seems whatever I do to the library doesn't affect the app.
It seems like it's using another library from totally different folder, I don't know, I tried searching for DonutProgress on my computer but didn't find anything that seems useful.
Please help.
When you add compile 'com.github.lzyzsd:circleprogress:1.1.0#aar' to your build.gradle dependencies, you are telling Gradle to go fetch this library from a repository when you build.
For most Android apps, this means that when you do a build, Gradle will go and download the library (in this case a .aar) from jCenter. This is good because it means you no longer need to manage the JARs (or other library files) yourself.
If you want to use a custom version of that library, then you should not add that dependency to your Gradle build script. Instead you should add it as either a module or a local dependency (e.g. compile files('libs/custom_library_name.aar')).

After creating android project in Eclipse ADT, tons of errors show up

I'm using eclipse ADT (most recent version) to develop some android apps. I've followed the getting started tutorial at the dev.android.com and it worked just fine.
But when i tried to create another project with the same targets and sdk's, i've got nothing but errors:
Some errors and my sdk's:
That's the same sdk's i used before these errors started showing up.
What can be causing this?
EDIT: my project won't generate the R.java file
You might need to add a support library to your new project.
Check this link for downloading the support libraries -
http://developer.android.com/tools/support-library/setup.html#download
Please notice that you need to import them into your eclipse and then include one (preferably the newest, not sure about this) in your project.
EDIT:
Before downloading the support libraries you should first check if you have them already.
Try this, right click project folder in the eclipse package explorer, Properties>Android>Library>Add>select a library if you have one.
There might be an invalid library included in your project already, if that happens then you will see it in the Library>Add> menu, remove it and add a new one.
You might have clean your project ........
if yes.....you must check whether R.java file is present in **Project(your project)->gen->package name->R.java**
if not than u have to update Tool Folder in SDK manager

Trouble importing and running the Google Cardboard sample project

You can find the project here: https://github.com/googlesamples/cardboard
The last time I worked with android was about a year ago and I'm trying to use this VR project to get back into it. All I want to do is mess around with the app to get a feel for it.
However, I haven't been able to get it running. I installed a fresh copy of Eclipse (juno) with the JDK and android SDK and got the android 4.4W stuff from the SDK manager. I also made a Nexus 5 AVD.
My problem is that I've tried choosing multiple 'root' folders to 'import as existing android project' and none of them have been runnable. Each time the eclipse terminal gives an 'Installation error: Unknown failure' error after installing 'MainActivity.apk'.
I figured the 'main' folder would be most likely to work since it has the manifest and all the other folders associated with android projects.
How do I get it running?
#CommonsWare: I have the project up and running on Eclipse(Juno) with Android 4.4.2
#ThroatOfWinter: These steps should help you. They worked for me.
Download the project from github as a ZIP file
Extract the contents of the ZIP file (named cardboard-master) into a folder and then import the whole folder into Eclipse as a new android project
Create a new "libs" folder in your project
To use the Cardboard API, download the VR Toolkit .jar file and include it in your project in the "libs" folder.
If everything has worked fine so far, you'll find that the "src" folder in your new Cardboard project is empty but the "java" folder contains 3 .java files.
Create a new package in "src" called "com.google.vrtoolkit.cardboard.samples.treasurehunt"
Copy the 3 files from the "java" folder and paste in the package you created in the previous step.
Clean and build the project
Test on an android device (preferably) with the cardboard app installed
You shouldn't need to edit the manifest at all.
That is not an Eclipse project. It is for use with Android Studio and Gradle. Your choices are:
Switch to Android Studio, or
See if somebody else has already reorganized that code into an Eclipse project, or
Attempt to reorganize it yourself, moving the contents of src/main/ into appropriate locations and fixing up the manifest for things that are set now in build.gradle, or
Find something else as a project to get back into Android development
This alternative worked for me: https://github.com/raasun/treasurehunt
It's pretty much the same as the Cardboard sample project from Google except that it's compiled with Eclipse/ANT instead of Android Studio/gradle.
Just follow the first part of moyheen's instructions to set it up.
To make it work on Eclipse, I just placed the Cardboard API jar (cardboard.jar) at the root folder of my app (alongside AndroidManifest.xml), and then in Build Path dialog I just did "Add Jar" and selected cardboard.jar.
Warning: Placing cardboard.jar in libs/ folder won't work, I tried, and it will produce an invalid APK that can't be installed.

android-support-v7-appcombat jar mismatch and app crashing after Android 4.4 SDK update

I have been successfully using android-support-v7-appcompat library for last few months in my app to support action bar in older devices. Recently I have downloaded the Android 4.4(kitkat) updates with system image and SDK platform from the SDK Manager. I also added targetSdkVersion to "19" in manifest file. But my project was showing error as 'android-support-v7-appcompat jar mismatch. Fix your dependaecies.' Then I added the jar from /extras/android/support/.... to the project as an external jar using build path menu > add external jar. Now there is no error in the project and android-support-v7-appcompat.jar & android-support0v4.jar file is showing twice under 'Referenced Libraries' folder and also once under 'libs' folder. The project is not showing error and running, but crashing in different activities.
Previously I imported the android-support-v7-appcombat library as an external project in the workplace. I can see error in that project. Please suggest what should I do now. Also, android-support-v7-appcompat.jar umder Android Dependencies in Java Build Path showing error.
The error I see is:
Found 2 versions of android-support-v7-appcompat.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All versions of the libraries must be the same at this time.
Versions found are:
Path: C:\<project hierarchy>\libs\android-support-v7-appcompat.jar
Path: C:\Users\....\sdk\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar
Jar mismatch! Fix your dependencies
After getting idea from different forum, I removed all the android-support-v7-appcompat libraries from different places, and imported android-v7 support library again in the project. Still it's showing error. Should I also delete android-support-v4 libraries from buildpath and libs/private librariry/referenced library folders?
This error occurs when there are multiple and different instances of the same library are found in the same project, or libraries used by it. A very simple way to resolve this is use the common lib at both the places. To do so:
Just copy your C:\Users....\AppData\Local\Android\android-studio\sdk\extras\android\support\v7\appcompat\libs\android-support-v7-appcompat.jar
and paste it in your libs folder, replace the old one with this. Clean the project, and it shall compile now..
Edit 1:
Basically the idea is if you are using the same libraries, it shall be the common jar, or the same jar.
In your case if you are using the appv7 as an external project, please go to libs folder of your project copy android-support-v4.jar, and paste into the libs of android-support-v7-appcompat project.
Also, make sure if there are other external jars or support libraries used by you, they shall be the similar jars in all the projects you are using.
I hope it helps!
I had exactly the same problem after installing all the updates mentioned in the question. I am sure there are different ways to solve this problem. Here is the way I used:
Previously, when an activity was created, the following project was automatically generated by the wizard:
androi-support-v7-appcompat and this project was added to the build path.
After all the updates, the following equivalent is generated when an activity is created:
appcompat_v7 with the jars of the same names.
I deleted androi-support-v7-appcompat and made sure the projects use appcompat_v7 to replace androi-support-v7-appcompat in their build paths. This made hundreds of errors generated by the duplicates go away.
I am glad that i finally found the answer. I was encountering the same problem again and again and i was like fed up.
Here is the answer to your question.
whenever you get such an error just don't touch anything other than libs folder. Just go directly into the libs folder and right away delete the android-support-v4.jar. and clean build your project. You will be relieved to get rid of errors.
Hope its useful to you.
Keep coding..
I have actually figured out the solution by trying different options suggested from different forum. I had manually change the android-support-v7-appcompat project's(which was added as an external project) project.properties file and had to set 'target=android-19'.

After adding library to android project, the XML tag is still "unallowed in Android resource files"

I've been trying to add a library called 'Android Plot' into my project, however I cannot seem to get past this error. Screen shots are below. This library has worked in other test projects I have done before.
I am using Android Studio. Suggestions about how I can get past this would be great. Thanks
Figured it out. AndroidStudio is still in it's "ghetto" stage so if you try to add a library dependency in typical IntelliJ fashion you get a warning telling you that whatever you do in the project/module dialog (which shows up when you select it) actually has no effect on your build and that you must edit build.gradle manually.
In the case of Androidplot 0.5.2 heres what you do:
Add androidplot-core-0.5.2.jar into your /libs dir
In the dependencies section of build. gradle add:
compile files('libs/androidplot-core-0.5.2.jar')
Once you've done this you should be OK.
Nick

Categories

Resources