I'm trying to use a jar file in an android application on the linux command line. I've read:
Android include .jar in ant compilation
Which is the same thing but never got a working answer.
Tried this:
How to add external jar libraries to an android project from the command line
but it didn't work, still gave the same error message.
The error is:
-compile:
[javac] Compiling 4 source files to /home/bianca/Documents/sem12012/FIT3140 /code/jackson-example/bin/classes
[javac] messagemain.java:4: package org.codehaus.jackson.map does not exist
[javac] import org.codehaus.jackson.map.ObjectMapper;
[javac] ^
[javac] messagemain.java:21: cannot find symbol
[javac] symbol : class ObjectMapper
[javac] location: class messagemain
[javac] ObjectMapper mapper = new ObjectMapper();
[javac] ^
[javac] messagemain.java:21: cannot find symbol
[javac] symbol : class ObjectMapper
[javac] location: class messagemain
[javac] ObjectMapper mapper = new ObjectMapper();
[javac] ^
[javac] 3 errors
BUILD FAILED
/home/bianca/Downloads/android-sdk-linux/tools/ant/build.xml:602: The following error occurred while executing this line:
/home/bianca/Downloads/android-sdk-linux/tools/ant/build.xml:622: Compile failed; see the compiler error output for details.
So I'm guessing it's a problem with importing the jar. I have the jar stored in ./lib.
EDIT:
I put the jar in libs according to a suggestion in an answer, it gives the same error.
ant.properties is all comments, local.properties and project.properties have not been changed from the automatically generated one. build.xml has not been changed, it's just the automatically generated one.
Use libs/, not lib/. The JAR will automatically be included as part of the compile process, and the JAR's contents will be packaged into your APK.
When building using Eclipse "run", you can have imported JARs even in subfolders of the libs folder - you can, for example, have it in libs/somefodler/somJar.jar. The Ant script shipped with the SDK, however, expects it directly in the libs folder, and not a subfolder.
Related
I'm trying to compile the examples included in GStreamer. I'm following this tutorial
but I can't compile any of the included examples because ant debug give me this error:
-compile:
[javac] Compiling 4 source files to F:\Android\gstreamer\share\gst-sdk\tutorials\android-tutorial-1\bin\classes
[javac] F:\Android\gstreamer\share\gst-sdk\tutorials\android-tutorial-1\src\com\gst_sdk_tutorials\tutorial_1\Tutorial1.java:8: package com.gstreamer does not exist
[javac] import com.gstreamer.GStreamer;
[javac] ^
[javac] F:\Android\gstreamer\share\gst-sdk\tutorials\android-tutorial-1\src\com\gst_sdk_tutorials\tutorial_1\Tutorial1.java:20: cannot find symbol
[javac] symbol : variable GStreamer
[javac] location: class com.gst_sdk_tutorials.tutorial_1.Tutorial1
[javac] GStreamer.init(this);
[javac] ^
[javac] 2 errors
BUILD FAILED
F:\Android\android-sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
F:\Android\android-sdk\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.
Total time: 1 second
I have installed the latest version of android ndk and android sdk, I'm using API 19 and gstreamer 1.7.1 (gstreamer-1.0-android-arm-1.7.1.tar.bz2) downloaded from here; I'm using CygWin64 as required in the tutorial and ANT from Apache. I have also declared all the required local variables.
I can run the first command: android update project -p . -s --target 19
and also the second: ndk-build
If the compiling process is not possible with the command line, where can I get a working version of Eclipse with adt plugins?
I solved: since I'm using Gstreamer 1.7.1 the import line import com.gstreamer.GStreamer; must be changed into import org.freedesktop.gstreamer.GStreamer;.
My android project is located in directory D:\testandroid\bin\app1.
I cannot build it because android build procedure sets wrong jars path.
D:\testandroid\bin\app1> and debug
...
-pre-compile:
[echo] Set jars path to: D:\testandroid\ant-build\app1\libs\CordovaLib.jar
-compile:
[javac] Compiling 3 source files to D:\testandroid\bin\app1\bin\classes
[javac] D:\testandroid\bin\app1\src\com\phonegap\testapp\TestApp.java:23: package org.apache.cordova does not exist
[javac] import org.apache.cordova.*;
As you can see it sets jars path to D:\testandroid\ant-build\app1\libs\CordovaLib.jar, but correct jars path should be D:\testandroid\bin\app1\libs\CordovaLib.jar
It replaces bin directory with ant-build directory by some reason.
How to fix this problem?
Unfortunately I cannot move android project from bin directory.
I'm trying to create a script to automate the signed exportation of my android apps (to avoid manual work when I release an update to all my apps).
I've followed this tutorial: http://www.enterra-inc.com/techzone/using_ant_android_applications_building/
and others, very similar to this one.
I'm testing with 1 project by now, which includes mopub-sdk library, among others and I get a lot of errors, like this one (only with ANT build):
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdFetcherTest.java:62: error: static import only from classes and interfaces
[javac] import static org.mockito.Mockito.verify;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdFetcherTest.java:64: error: cannot find symbol
[javac] #RunWith(SdkTestRunner.class)
[javac] ^
[javac] symbol: class RunWith
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:41: error: package org.junit does not exist
[javac] import org.junit.Before;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:42: error: package org.junit does not exist
[javac] import org.junit.Test;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:43: error: package org.junit.runner does not exist
[javac] import org.junit.runner.RunWith;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:58: error: package org.fest.assertions.api does not exist
[javac] import static org.fest.assertions.api.Assertions.assertThat;
[javac] ^
[javac] D:\Documents\Applications\Eclipse\Projects\mopub-sdk\src\test\java\com\mopub\mobileads\AdLoadTaskTest.java:58: error: static import only from classes and interfaces
When I compile with Eclipse, everything is fine.
I think I did everything OK, but there is only 1 thing that is bothering me.
For some reason, when I imported the mopub-sdk project, it showed src/main/java directory instead of just src like the rest of the projects.
So, my question is:
1) How can I solve these errors so I can finally build automatically all my apps.
2) It the folder structure of mopub-sdk is the cause of the problem: how can I solve it?
UPDATE:
While trying to reimport the mopub-sdk project, I'm getting this error.
I found the solution.
The problem was finally mopub-sdk library project and the problems at the import stage.
I fixed the nested directory issue within the src/ folder and the build was successful.
To fix our ANT build remove the 'test' folder under src and the compile errors in ANT went away.
Specifically the files in this part of the downloaded SDK:
https://github.com/mopub/mopub-android-sdk/tree/master/mopub-sdk/src/test
I just download latest facebook SDK from github. I import my facebook SDK into my cordova project, then when I try to build project using cordova build android, I'm always got this error in my terminal. I already done ant clean release, the error still remain. Currently using android sdk 19.
-compile:
[javac] Compiling 94 source files to /Users/MNurdin/Documents/Github/facebook-android-sdk/facebook/bin/classes
[javac] /Users/MNurdin/Documents/Github/facebook-android-sdk/facebook/src/com/facebook/widget/WebDialog.java:349: warning: [deprecation] setSavePassword(boolean) in android.webkit.WebSettings has been deprecated
[javac] webView.getSettings().setSavePassword(false);
[javac] ^
[javac] /Users/MNurdin/Documents/Github/facebook-android-sdk/facebook/src/com/facebook/widget/PickerFragment.java:638: warning: [deprecation] setBackgroundDrawable(android.graphics.drawable.Drawable) in android.view.View has been deprecated
[javac] titleBar.setBackgroundDrawable(titleBarBackground);
[javac] ^
[javac] /Users/MNurdin/Documents/Github/facebook-android-sdk/facebook/src/com/facebook/widget/PickerFragment.java:660: warning: [deprecation] setBackgroundDrawable(android.graphics.drawable.Drawable) in android.view.View has been deprecated
[javac] doneButton.setBackgroundDrawable(doneButtonBackground);
[javac] ^
[javac] 3 warnings
BUILD FAILED
/Applications/android-sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Applications/android-sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
I already search the answers through stackoverflow but still can't get the solution.
I already found the answer. No need to use facebook SDK. I using this one instead facebook SDK from facebook.
https://github.com/phonegap-build/FacebookConnect
I'm trying to run a phonegap application with the PushPlugin installed.
I adde the plugin with this command:
$ phonegap local plugin add https://github.com/phonegap-build/PushPlugin
and it went through ok.
I added the PushNotification.js file to my "www" folder and referenced it in index.html.
Then I added some code to handle notifications in my index.js file.
I tried to run the application:
$ phonegap local run android
and got this:
-compile:
[javac] Compiling 8 source files to /Users/nadavelyashiv/Code/PushNotificationSample/platforms/android/bin/classes
[javac] /Users/nadavelyashiv/Code/PushNotificationSample/platforms/android/src/com/plugin/gcm/GCMIntentService.java:96: cannot find symbol
[javac] symbol : method getString(java.lang.String)
[javac] location: class com.plugin.gcm.GCMIntentService
[javac] .setTicker(getString("title"))
[javac] ^
[javac] /Users/nadavelyashiv/Code/PushNotificationSample/platforms/android/src/com/plugin/gcm/GCMIntentService.java:95: cannot find symbol
[javac] symbol : method getString(java.lang.String)
[javac] location: class com.plugin.gcm.GCMIntentService
[javac] .setContentTitle(getString("title"))
[javac] ^
[javac] 2 errors
BUILD FAILED
/usr/local/Cellar/android-sdk/r22.0.4/tools/ant/build.xml:720: The following error occurred while executing this line:
/usr/local/Cellar/android-sdk/r22.0.4/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
What seems to be the problem here?
Thank you.
Found issue, created a PullRequest on project :
https://github.com/phonegap-build/PushPlugin/pull/83/files
You should update the code of line 95 and 96 of android/com/plugin/gcm/GCMIntentService.java
.setContentTitle(extras.getString("title"))
.setTicker(extras.getString("title"))