I have an android gradle project which I compile from the command line. I am using eclipse + eclim to have autocompletion and source code validation. I was an unable to get code completion to work by importing the project as an gradle project into eclipse. I therefore imported /path/to/gradle/project/app/src/main as an android project into eclipse and after some .classpath tweaking I was able to get autocompletion to work.
Now I wanted to import the following android support libraries:
import android.support.annotation.NonNull;
import android.support.v13.app.FragmentCompat;
import android.support.v4.app.ActivityCompat;
but got The import ... cannot be resolved error for all three lines. I then tried Android Tools -> Add Android Support Library which failed miserably. I then tracked down the libraries in question in the Android-SDK and added them manually to the Java Build Path in Eclipse. For some I needed to extract the JAR files from the AAR files as described in this answer. I added the following libraries:
appcompat-v7-26.0.0-alpha1.jar
support-annotations-26.0.0-alpha1.jar
support-v4-26.0.0-alpha1.jar
support-v13-26.0.0-alpha1.jar
This solved the problem for the the first two imports but I still get the error for import android.support.v4.app.ActivityCompat;. I have code completion up to v4 but app is not found.
How can I resolve this issue? Am I still missing some dependency? Is there a better way to get android code completion with eclim?
So i figured it out myself. There was still a dependency missing. In my case I also needed
support-compat-26.0.0-alpha1.jar
I wrote this script to extract all the jar class files that are somewhere hidden in the android-sdk/folder. It recursivly looks at all subdirectories of the specified Android SDK folder until it either finds a JAR file which is not Javadoc or Source and copies it to a destination directory. If an AAR file is found the content is extracted to a folder of the same name as described in the link of the question and the JAR file in that folder copied with an appropriate name to the given destination directory.
Related
There is sample code on the developer site that i wish to run.
When I import as a new Android Studio project, I'm not given any ability to run the code (disabled buttons).
I attempted to copy the source files over into the shell of a new project, but i than got errors that didn't make sense. reference to duplicate declarations in source files that had nothing relating inside them.
Is there an idiots guide on how to properly use android studio, or is it just this difficult?
In order to correctly import the project, you should follow the Samples guide as found in the developer docs.
To import a downloaded project:
Unpack the downloaded project package.
In Android Studio, chose File >
Import Project and select the root folder of the unpacked project.
Android Studio may ask you to choose the type of project you are
importing.
If this is the case, make sure to choose Import project
from external model and select the Gradle option.
Alternatively, if the Gradle option does not work, I would attempt to use the Eclipse option.
Open .gradle file when you import the project, not the folder of the proyect.
I am trying to use opencv in android studio but am having some problems. I have searched the forums but couldn't find this exact problem. I am clicking file > import module and entering the following file path: OpenCV-2.4.10-android-sdk\sdk\java
I then receive an import summary like this:
ECLIPSE ANDROID PROJECT IMPORT SUMMARY
Ignored Files:
The following files were not copied into the new Gradle project; you
should evaluate whether these are still needed in your project and if
so manually move them:
javadoc\
javadoc\allclasses-frame.html
javadoc\allclasses-noframe.html
javadoc\constant-values.html
javadoc\help-doc.html
javadoc\index-all.html
javadoc\index.html
javadoc\org\
...
the summary includes a lot more libraries that are not included but I didn't want to list pointless additional information.
...
Moved Files:
Android Gradle projects use a different directory structure than ADT
Eclipse projects. Here's how the projects were restructured:
AndroidManifest.xml => openCVLibrary2410\src\main\AndroidManifest.xml
lint.xml => openCVLibrary2410\lint.xml
res\ => openCVLibrary2410\src\main\res\
src\ => openCVLibrary2410\src\main\java\
src\org\opencv\engine\OpenCVEngineInterface.aidl => openCVLibrary2410\src\main\aidl\org\opencv\engine\OpenCVEngineInterface.aidl
Next Steps:
You can now build the project. The Gradle project needs network
connectivity to download dependencies.
Bugs:
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.
(This import summary is for your information only, and can be deleted
after import once you are satisfied with the results.)
Can anyone help me with this issue please?
Even if ".html" files are not copied the code will work.
Instead of importing path:"OpenCV-2.4.10-android-sdk\sdk\java" import any one of the samples from the opencv sdk 4 android and the libraries will be imported automatically eg:-(path:"OpenCV-2.4.11-android-sdk\OpenCV-android-sdk\samples\15-puzzle") then you can always remove the module from properties.
I am working on a currency wallet app. I have downloaded code from here.
I have imported this code in my eclipse, also i have inserted some libs(.jar files). I have downloaded maven code for java from here.
Now in android project in eclipse there are some compile time errors found like.
The import com.google.bitcoin.params cannot be resolved
and so on.
So please can anybody help me to build bitcoin project without error ?
Where to found following packges and How to import following packages ?
**The import javax.annotation cannot be resolved
The import org.slf4j cannot be resolved
The import com.google cannot be resolved
The import de.schildbach.wallet_test.R cannot be resolved
The import org.bitcoinj cannot be resolved
The import ch cannot be resolved`enter code here`
The import org.spongycastle cannot be resolved**
Thank you in advance.
You need to get each of those libraries and add them to your project:
Put the JAR file in the /libs folder in the root of your project (create the libs folder if it doesn't exist)
If necessary, right-click the JAR file and select Build Path → Add to Build Path
If necessary, clean the project (Project → Clean)
For javax.annotation, for example, you would use this libarary:
http://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
Just click the latest version number and then click Download.
If you have a dependency that you can't find a JAR file for, you can download the source and add that project as a library dependency for your project: https://stackoverflow.com/a/8281477/399105
More resources:
Adding libraries without resources
Adding a library/JAR to an Eclipse Android project
Android: The import javax.annotation cannot be resolved
I am trying to utilize the Zip Expansion library from Google in my app, but I cannot seem to import the libraries correctly.
Right now, in my code, to test the library, I am using :
ZipResourceFile expansionFile = new ZipResourceFile();
This is throwing errors because I have not imported the expansion library correctly.
From scratch, could someone tell me how to use this library in my project?
Thanks so much.
In Eclipse, import the 'zip_file' project (using 'copy projects into workspace' option). Add a reference to this project under your project properties, then add the project to your Java Build Path. Add the namespace to your code file:
import src.com.android.vending.expansion.zipfile.*;
Using ZipResourceFile should not throw any errors at this point. You should also mark this dependency as an Android library under your project properties so that it will be managed properly when building.
I am trying to understand the Tabs + ViewPager concepts in Android where I found this code while googling, http://thepseudocoder.wordpress.com/2011/10/13/android-tabs-viewpager-swipe-able-tabs-ftw/. I was just trying to copy paste and I found that:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
These 3 packages are unable to find their way i.e they are marked as an Error in my Eclipse and I am not very sure what to do with these packages.
Anybody help me in getting that right and please let me know why these packages are used for?
see here:
http://developer.android.com/tools/extras/support-library.html#SettingUp
it basically says:
In your Android project, create a directory named libs at the root of your project (next to src/, res/, etc.)
Locate the JAR file for the library you want to use and copy it into the libs/ directory. For example, the library that supports API level 4 and up is located at /extras/android/support/v4/android-support-v4.jar.
Add the JAR to your project build path: In Eclipse, right-click the JAR file in the Package Explorer, select "Build Path > Add to Build Path".
(This step seems not to be necessary when using linux command line tools.)
NOTE: make sure you visit the link above for some important additional information
You need to add the jar file from the sdk path. Found here
(Your android sdk path$>
android-sdk-windows\extras\android\compatibility\v4
and add android-support-v4 to your build path.
This is needed for using fragments.
Add appropriate Android support library to your project by doing the following:- Right click on project >> Android Tools >> Add support library
What API level you given to your Project...cause Fragment is available since Android 3.0..and for lower level api to use it,you will have to use jar file From Here