I have been trying endlessly to build the sample HelloJni sample project for the Android NDK.
How I set up the environment:
I followed the instructions of the getting started in the docs: android-ndk-r10d\docs\Getting_Started/html/index.html:
Downloaded Eclipse Luna
Downloaded the Android SDK
Downloaded the Android NDK: android-ndk-r10d
Set the NDK installation folder in eclipse in preferences window -> android -> NDK.
Imported the hellp-jni sample.
Right click on the HelloJni Project -> Android tools -> Add native support.
Cleaned and Built the project.
Ran on my device the HelloJni library (not the tests)
And the app is running and everything is WORKING and I can see the generated .so file per architecture in the libs folder of the project (for every architecture, for example armebi, mips, etc...)
Here is a Print Screen showing everything is working:
Now here comes the strange part...
The Problem:
If I open the hello-jni.c file for editing or viewing in eclipse, I suddenly see compilation errors and I can't build and can't run the project anymore...
Here is a Print Screen showing that after i open the file, I suddenly get compilation errors:
What I have already tried but failed:
Adding the Android Native Nature, then removing it by:
Deleting the .project file,
the buildCommand tag of: org.eclipse.cdt.managedbuilder.core.genmakebuilde,
the buildCommand tag of: org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
and removing the lines:
[nature]org.eclipse.cdt.core.cnature[/nature]
[nature]org.eclipse.cdt.core.ccnature[/nature] [nature]org.eclipse.cdt.managedbuilder.core.managedBuildNature[/nature] [nature]org.eclipse.cdt.managedbuilder.core.ScannerConfigNature[/nature]
removing the .cproject and all compiled files.
Then adding back the Android Native Nature.
According to this stackoverflow link:
Eclipse ADT - Unresolved inclusion jni.h
Failed
Once I got the error of (I am not getting it anymore): Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath". So I Googled and I changed the build settings to give the absolute path of my NDK installation folder:
According to this stackoverflow link:
Unable to launch cygpath in android
Here is a Print Screen:
Failed
Changing the Used tools from Android GCC Compiler to GCC C Compiler
according to this stackoverflow link:
Android NDK build, Method could not be resolved
Here is a Print Screen:
Failed
Copying an eclipse Luna installation from a friend that has the project working for him.
Failed
I have been spending hours on this and I couldn't find any solution to why this is happening.
PLEASE HELP
This is a common problem when you try to edit a C/C++ file inside a JAVA workspace/perspective without the proper configuration. You can simply select all the entries in the Error Log and delete them.
FWIW, Eclipse seems to have issues with the r10d version of Android NDK. See https://code.google.com/p/android/issues/detail?id=97023. I suggest you try r10c instead #worksforme :)
I have an Android project with native code. I'm able to build native code from command line by calling ndk-build command with no errors or warnings. But when I open it in ADT it shows the following error.
Error message: Method CallStaticIntMethod could not be resolved. There are many files with similar errors in the project.
I double checked configuration and here is what I have. Android build, tool chain and includes are properly configured (see pictures below)
Required includes are also visible in the Project Explorer and they are valid (not empty and point to correct header files).
But when I Clean the project and Build it, the errors are still there. Any ideas on how to solve this?
Configuration: ADT 22.6.2, NDK r9d (64-bit), OSX 10.9.2
After some struggling with preferences, I finally found a solution. This is a bug in NDK plugin which was reported to AOSP but not yet fixed. A past of the answer is described in comment #50. Here is the sequence which worked our for me.
Open Project Properties -> C/C++ Build -> Tool Chan Editor
In the section Used Tools replace Android GCC Compiler with GCC C Compiler. If section is empty, just add GCC C Compiler entry in there.
Open Project Properties -> C/C++ General -> Paths and Symbols and add directories, where your h-files to be included are located. Use Move up button to add a folder with your local includes (/AudioPlayer/jni in my case) to the first place. Then add platform and toolchains includes. Built-in includes should stay at the very bottom.
In my case the full paths to the toolchain includes were like below. These are built-in paths of original Android GCC Compiler toolchain, which we have replaced at step 2.
/Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include
/Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include-fixed
Press OK button, clean and re-build the project. All errors must go away. If they stay, try to remove them from Problems view and re-build project once again.
Update: I have found another place, where you can add paths to include files. However it appears to be Eclipse version dependent. Project Settings -> C/C++ General -> Processor Include Paths, Macros etc. -> CDT User Settings Entries -> Add. After I added the paths listed above, there is no compilation issues anymore. Development is fun again.
Yes, its caused by the IDE not knowing where all of your headers and any libs you linking again are. The errors are generated by the IDE's autocomplete/bug system. You can either fix your includes within eclipse or remove them as errors in the preferences.
I had a similar error and solved it by going to project->properties->discovery options and changing the discovery profile from managed build system to GCC, after changing to GCC C Complier from Android GCC Compiler and updating the include directories.
I started using new Android Studio and cant find the APK of the application in IDE,where it actually locates?
To help people who might search for answer to this same question, it is important to know what type of projects you are using in Studio.
Gradle
The default project type when creating new project, and the recommended one in general is Gradle.
For a new project called "Foo", the structure under the main folder will be
Foo/
settings.gradle
Foo/
build.gradle
build/
Where the internal "Foo" folder is the main module (this structure allows you to create more modules later on in the same structure without changes).
In this setup, the location of the generated APK will be under
Foo/Foo/build/apk/...
Note that each module can generate its own output, so the true output is more
Foo/*/build/apk/...
EDIT
On the newest version of the Android Studio location path for generated output is
Foo/*/build/outputs/apk/...
IntelliJ
If you are a user of IntelliJ before switching to Studio, and are importing your IntelliJ project directly, then nothing changed. The location of the output will be the same under:
out/production/...
Note: this is will become deprecated sometimes around 1.0
Eclipse
If you are importing Android Eclipse project directly, do not do this!
As soon as you have dependencies in your project (jars or Library Projects), this will not work and your project will not be properly setup.
If you have no dependencies, then the apk would be under the same location as you'd find it in Eclipse:
bin/...
However I cannot stress enough the importance of not doing this.
I am on Android Studio 0.6 and the apk was generated in
MyApp/myapp/build/outputs/apk/myapp-debug.apk
It included all libraries so I could share it.
Update on Android Studio 0.8.3 Beta. The apk is now in
MyApp/myapp/build/apk/myapp-debug.apk
Update on Android Studio 0.8.6 - 2.0. The apk is now in
MyApp/myapp/build/outputs/apk/myapp-debug.apk
There is really no reason to dig through paths; the IDE hands it to you (at least with version 1.5.1).
In the Build menu, select Build APK:
A dialog will appear:
If you are using a newer version of Android Studio, it might look like this:
Clicking the Show in Explorer or locate link, you will be presented with a file explorer positioned somewhere near wherever Android Studio put the APK file:
But in AS 3, when you click locate, it puts you at the app level. You need to go into the release folder to get your APK file.
In my case, I'm using Android Studio 1.0.2, I get my APK file from:
<myAndroidProject>/app/build/outputs/apk/app-debug.apk
If anyone would be missing his APK and couldn't find it in the locations stated in other answers (I found this question, since I couldn't find it either) it might just be in this folder (mine was)
<project folder>/target/classes/<appname>.apk
I also had a there this file:
<appname>.unaligned.apk
I am not perfectly sure, whether the apk is actually the full-blown apk, which should be generated, but I tried it on various devices (not only the target device, but also those which were supporting only the minimum SDK) and it worked.
Hope this will help someone.
It is Project_Location/app/build/outputs/apk for Gradle Project
Find apk using below step:-
Goto to your project folder.
Open project folder.
Open build folder.
Open output folder.
Open apk folder.
Now you see your apk.
hope it will help some body.
So the apk in Android studio is generated inside build folder of app module.
Correct path to apk would be \app\build\outputs\apk. I am using Android Studio Version 1.4.1. So apk could either be found at app/build/apk/ or \app\build\outputs\apk base on the version of Android studio you are using. Refer the below image
Also find more reference on these links.
Building and Running from Studio
Studio Project Overview
I'm using Android Studio and gradle.
It created the build/apk/<.apk> file only when I ran the project.
Press the following to run your project: Alt+u, u
Android Studio: 0.5.3
Gradle: 0.9.+
You can find the APK in:
YourProject\app\build\outputs\apk
The .apk file is located at [your project]\out\production\[your project name]
In the new Android Studio, the signed apk is placed directly in the folder of module for which the apk is built.
For example: For a Project ProjectA containing 2 modules Mod1 and Mod2, the apk files will be found in
/path-to-ProjectA/Mod1/Mod1.apk
/path-to-ProjectA/Mod2/Mod2.apk
Image for APK location in Android Studio
Location of apk in Android Studio:
AndroidStudioProjects/ProjectName/app/build/outputs/apk/app-debug-unaligned.apk
As of version 0.8.6 of Android Studio generating an APK file (signed and I believe unsigned, too) will be placed inside ProjectName/device/build/outputs/apk
For example, I am making something for Google Glass and my signed APK gets dropped in /Users/MyName/AndroidStudioProjects/HelloGlass/glass/build/outputs/apk
I got the .apk files in
parent_folder/out/production/projectname/projectname.apk
Build your project and get the apk from your_project\app\build\apk
You can find your apk file as follow:
yourproject>app>build>output>apk>yourproject.apk
The Android build system is the toolkit you use to build, test, run
and package your apps. The build system can run as an integrated tool
from the Android Studio menu and independently from the command line.
You can use the features of the build system to:
Customize, configure, and extend the build process.
Create multiple APKs for your app with different features using the
same project and modules.
The build process involves many tools and processes that generate intermediate files on the way to producing an .apk. If you are developing in Android Studio, the complete build process is done every time you run the Gradle build task for your project or modules.
The build process is very flexible so it's useful, however, to understand what is happening under the hood since much of the build process is configurable and extensible. The following diagram depicts the different tools and processes that are involved in a build:
Build a release version
You can now use the Build menu options to build the release version of your application for distribution.
The build generates an APK for each build variant: the app/build/apk/ (or app/build/outputs/apk) directory contains packages named app--.apk; for example, app-full-release.apk and app-demo-debug.apk.
Build output
The build generates an APK for each build variant in the app/build folder: the app/build/outputs/apk/ directory contains packages named app--.apk; for example, app-full-release.apk and app-demo-debug.apk.
Courtesy goes to Build System Overview
I am using Android Studio 3.0 canary 6.
To build apk,
Click to Build->Build APK(s).
After your apk is build, Go to:
C:\Users\your-pc-name\AndroidStudioProjects\your-app-name\app\build\outputs\apk\debug
If you have imported a Project from Eclipse and are using the new Android Studio
The directory
/bin
does exist (there maybe old binaries in here) however with the latest Android Studio update the actual current apk is stored in
/out/production
Add this in your module gradle file. Its not there in default project. Then u will surely find the APK in /build/outputs/apk/
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
open Event Log
find line: Module 'app': locate or analyze the APK.
click on locate link to open folder with apk file!
After all: "All built APKs are saved in project-name/module-name/build/outputs/apk/ Build your project LINK
Hint: If you can´t see the app-debug.apk in your debug folder, you have to click on BUILD --> Rebuild Project in Android Studio.
To create apk in android studio,go to build menu->build bundles/apk->build apk
it will make the apk file of your project.After this the apk will be available in your
project directory->app->build->outputs->apk->debug->app-debug.apk
Click on Build-Build Bundles/Apks-Build Apk.
A notification will which shows app location when you click on 'locate' on the notification.
If you have already done creating apk, goto : C:\Users\\AndroidStudioProjects\\app\build\outputs\apk\debug
For Gradle look here: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSetOutput.html.
"For example: Java plugin will use those dirs in calculating class paths and for jarring the content; IDEA and Eclipse plugins will put those folders on relevant classpath."
So its depend on plugin build in configs unless you don't define them explicit in config file.
Click the little gear icon in the project view and make sure "show excluded files" is checked. Otherwise, the IDE will hide output and several other important directories under $project/$module/build/.
Hello all above all answers are right you can find the apk through the path in android studio but there is exceptions you can't find the build/output
folder some times if you can't see it just go to
app--> app.iml file and find below line in it :-
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
--> after removing this line you can see the output folder its just the adding more information to above answers as per my experience :)
THANKS!~!
For Android Studio 2.0
C:\Users\UserName\AndroidStudioProjects\MyAppName\app\build\outputs\apk
Here
UserName is your computer user name and
MyAppName is your android app name
As of Android Studio 3.0 / Gradle Build Tools 3.0.0, APK artifacts can now be found in foo/bar/build/outputs/apk/flavorName/buildType with respect to your project name, foo, and your module name, bar. There is now a directory for each apk file sorted organized first by flavor (with respect to flavor dimensions) and then by build type.
I know this is a repeat question but I've read and tried every solution on this site and I'm still getting the error; also, I'm getting it ONLY when I export my signed apk from Eclipse. I'm able to build and run the unsigned apk.
I have:
Deleted (and later restored) all libraries from the build path
Cleaned and rebuilt all my projects
Restarted Eclipse with -clean option
Re-create the app project from scratch
I know error 1 means I have duplicate symbols but I've checked, clean and rebuilt my build path a million times and I still get the error, only when I export.
If I had duplicate symbols, wouldn't I get an error 1 for my unsigned apk too?
If I really do have duplicate symbols, how can I get Eclipse to tell me what they are? All I get from the export wizard is a one-line error dialog. :(
I don't get any errors when I manually sign the apk, but when I install it on a phone I get a simple error: "Application not installed." :(:(
My project structure is as follows:
One Android library project with 99% of my code. It has one copy of the required jar files in the build path.
One Android app project with two classes. It references the library project via the Android tab, NOT the Java build path. There are no additional sources, projects or libraries referenced in the build path except for Android 2.1. I even re-created this project from scratch (I didn't re-created the library project because it's much bigger).
Everything was working a few days ago! Any suggestions are much appreciated!
Thanks in advance...
EDIT-UPDATE: The error goes away when I disable Proguard. Very strange.
This is an issue with Proguard in the Windows developer tools - edit Android SDK\tools\proguard\bin\Proguard.bat
Replace:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*
with:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
Keep a reference to this solution because next time you update the SDK tools it'll probably be reintroduced (has been present in last few releases).
Upgrade your Proguard to its latest version i.e., 4.7...
Dowload the zip from http://sourceforge.net/projects/proguard/files/latest/download?source=files .... then copy the "lib" and "bin" folders from the zip to your sdk/tools/proguard/ to replace the default or say old "bin" and "lib" .... try exporting your project once again...
Go to project and unselect Build Automatically. Then Clean the project and Build all. Worked for me to export signed application package
This was driving me insane too. I tried everything, changed all my external libraries and so on but nothing worked. I tried a newer version of proguard without success.
Turns out I was using a library called "GridLayout" to support older devices. After I renamed the class "GridLayout" to "CustomGridLayout" it worked fine. Seems like you can't have duplicate class names.
Here was the key that worked for me
http://android.foxykeep.com/dev/fix-the-conversion-to-dalvik-format-failed-with-error-1-with-adt-14
Supposedly fixed in ADT-15, the workaround is
1) For each X_src element,right click on it and then Build Path > Remove from build path.
2) A popup will open. Make sure that “Also unlink the folder from the project” is checked and then accept it.
You can still debug into library code but you need to manage your breakpoints in those projects and then step through the code in the class file tabs.
I tried a few of the above solutions, and had no luck. Then, I closed Eclipse, and re-opened it, and was able to export successfully. If I try again however, it wouldn't work.
So, I think maybe I only get one successful export per "open" of Eclipse. Not an ideal solution by any means, but when all else fails give it a shot. It worked for me.
The accepted answer to this question (from 2011) did not work for me. However, the correct answer to this question is posted here:
Android export give a "Conversion to Dalvik format failed error1"
Unselect Build Automatically works for me. Tanks anjaneya;
0)Unselect Build Automatically
1) Clean the project
2) Build project.
3) Export Signed Application in Android Tools options.
I'm getting the following error every time I try to export my application from Eclipse.
Proguard returned with error code 1. See console
proguard.ParseException: Unknown option 'and' in argument number 9
at proguard.ConfigurationParser.parse(ConfigurationParser.java:170)
at proguard.ProGuard.main(ProGuard.java:491)
I'm using the defualt proguard.cfg file that Eclipse generated. My android sdk is in C:\Android\SDK(here)
My default.properties file is like this:
target=android-7
proguard.config=proguard.cfg
I have also done a clean and build.
I also made sure Eclipse and my SDK tools were up to date.
The 'spaces in the pathnames' problem is well documented here - note that you can use Junctions/Links to get around this without moving or renaming files...
The Dalvik error is usually just Eclipse 'having a moment' - a 'Clean Project' and Rebuild usually cures it.
So, in my workspace for the name of the project I had C:\workspace\Name Android Name for the name, so I changed that to C:\workspace\NameName, then I changed my sdk to C:\sdk, then I exported to C:\NameAndroidName.apk, and I got the failure to convert to dalvik format error.
And then I went to this question and that solved the dalvik format error, and it exported successfully.