I'd like to use a module imported into Android studio in my Android project. My development is taking place in the app module and I have imported sliding-menu as a module and set the dependency in the IDE but gradle cannot find out the dependency and builds fail because of this. How can I tell gradle that I have imported the module?
If you add your dependency as a module, it doesn't mean it is included in your project. You should add it as a library next. Please read "approach 2" part of this link https://stackoverflow.com/a/35369267/5475941. It is exactly what you are doing. In this post I explained how to import your JAR files in Android studio and I explained all possible ways step by step with screenshots. I hope it helps.
Related
I am trying to setup an NDK library module structured very similar to the gen-libs module in the Android-NDK sample project. It identifies what I want in an Android NDK library module to allow me to incorporate 3rd party Native Libs:
src/main/cpp
CMakeLists.txt
Android manifest
build.gradle
I am NOT looking to add C or C++ source files to my app module.
Instead, I am looking to create an Android-NDK library module within Android Studio, so that I can incorporate 3rd Party Native Libs.
However, I am Unable to easily reproduce the structure of the gen-libs module in Android-NDK sample hello-libs.
More specifically, Android Studio does not provide any option to create a "New => Module => Android Library => Add NDK/C++ support"
I suppose I can recreate this NDK module manually, but before I do that, I would like to ask the community if, for a brand new project, is there any easy way to auto-create the gen-libs module structure from hello-libs beside manual method?
Feel free to use your copy/paste skills to produce the project manually. The wizard won't do it for you, at least for now.
You can also create an app project and switch it to library by changing one line in build.gradle.
You can also create a library module, right click on this module, and choose 'Link C++ Project with Gradle' from the popup menu (or from File menu).
There are answers about getting the tess-two project integrated into an Android project within Android Studio, but many are out-dated and none used the current capabilities defined here:
Using Android Studio 2.2 and higher, you can use the NDK to compile C and C++ code into a native library and package it into your APK using Gradle, the IDE's integrated build system. Your Java code can then call functions in your native library through the Java Native Interface (JNI)
What specific steps would be required to make tess-two functionality a part of the resulting APK, using functionality within Android Studio, rather than external file placement, manipulation and command line tools? So taking the building, creation of *.so files into the IDE. Specifically using just Android Studio's integrated build system (Gradle) as described here.
1. Start a new project
2. Import Tess-Two into the project
2b. Add any needed plug-ins
3. Add code in the main activity to get native functionality
4. Configure Android Studio build so that native functionality is available
This is where the specifics are required
4. Configure Android Studio build for native functionality
4a. Link C++ Project with Gradle
First, check the tess-two project for build files. You may select CMakeLists.txt or Android.mk files. Both are currently supported.
In this case, I used ndk-build, which seemed like a good bet for integrating the native code.
For more information, see Android Studio documentation
4b. Manage Long Commands
In Windows, errors may be encountered if the command length grows too large. To prevent problems, use LOCAL_SHORT_COMMANDS AND APP_SHORT_COMMANDS in the Android.mk file.
The "e=87" error is what you are avoiding by doing this:
For more on that topic, see stackoverflow question about error 87.
4c. Add Module Dependency for tess-two
In File > Project Structure > Dependencies use the + to add the tess-two dependency:
4d. Build the Project and check .apk file for .so files
The build, which takes a long time, should complete now. Validate that the .apk file contains the .so files, created during the build. With the tess-two libraries in an static initializer, run the project on your Android device:
I am trying to add a 3rd party library to my project.
But it keeps on giving this error:
Error:(10, 0) Could not find property 'VERSION_NAME' on project ':library'.
I am adding Floating action button library
Can someone mention me the proper steps how do I import it?
as mentioned in here in the link you provided. You just simply paste this into your Build.gradle file
compile 'com.getbase:floatingactionbutton:1.9.0'
If you want to learn more about android studio, check out this tutorial I made on getting started with android studio :D
I have downloaded the facebook sdk version 3.21.1 and I have android studio version 1.0.2.
Whenever I try to import the 'facebook' folder in the sdk folder(through the import module method), it dosent show up in the project tree on the left hand pane. Also I am getting this error : Error:(1, 0) Gradle DSL method not found: 'pply()'
Possible causes:The project 'The Social App' may be using a version of Gradle that does not contain the method.
Gradle settingsThe build file may be missing a Gradle plugin.
Apply Gradle plugin
Please help.
For me I was having similar problems.
I am using Android Studio 1.1 and Facebook SDK 4.0.0
First, be sure to follow that steps 3 to 6 in the facebook developers page in your existing project.
Click here for the getting started instructions.
Be very sure you follow it all.
After importing it I didn't see it in my project structure be sure to click down on the left corner and make sure it is on Project, if not use the drop down and select Project.
Also do ctrl+alt+shiftt+s to bring up the project structure wizard. Then go to app dependencies and click plus in the right corner to add the :facebook module dependency.
Then make sure that in your root project build.gradle that it's using gradle 1.1.1 since some problems with importing has been fixed here.
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Then referencing this answer was the finishing touch:
Can not import facebook-sdk 4.0.1
Then a pop should appear to upgrade buildToolsVersions to 21.1.1.
This is what it took for me to get this all working. Hope it works for you too!
I'm struggling badly with moving from Eclipse to Android Studio.
Basically, I get that an Android Studio project is more like a workspace and a module more like a project...
However, in the Android Studio start page you can only create projects, so how do you share a module (i.e. a project in eclipse terms) across projects?
Basically, I have a number of apps that use a shared library I've created, in Eclipse all I do is flag it as a library and in each project simply link to it.
I have absolutely no idea how to do this in Android Studio. The examples for creating modules seem to take you as far as creating a module for no real purpose other than to use it within one app.
I first imported my library as a project in android studio, but that proved pointless, thinking that was how to do it because I want it kept separate in my version control system.
I then created a temporary module inside my app, but then it stores it within the project and in my other apps I cannot find a way to import the modules, so I really don't see what the point of a module is when it's embedded in a project and can't be separated or referenced anywhere else.
Thanks for any help.
Consider your library project name common-lib
Open build.gradle of the projects to which you want to add library add add the following
dependencies {
compile project(':common-lib')
}
and sync gradle