I have imported my android Eclipse project into Android Studio 1.0. The import ignored all of my source code files, so I have manually added them to the project. The error that I am getting is found on all of the activity names found in my AndroidManifest.xml file. For example:
<activity android:name="com.company.myapp.beforelogin.InitialActivity"></activity>
The AndroidManifest is unable to resolve the symbols "beforelogin" and "InitialActivity". I have read here (AndroidStudio : Cannot resolve symbol MainActivity) that Android Studio doesn't recognize my code as source code. So I tried this (How to get Android Studio to recognize file as source (test)) to add my directory as a sourceSet in my build.gradle file, but it didn't work. My project structure looks like this:
-app
-src
-build.gradle
-main
-res
-com
-AndroidManifest.xml
Any help would be greatly appreciated. Thanks.
Assuming that com/ in your structure refers to the root package of your Java source, create a java/ directory as a peer of res/ (i.e., a child of main/) and move com/ into java/.
Related
I have made a Java Swing application and now I want to export it as an executable jar file. I have created the app in Eclipse, and it has the following structure :
where folder mysqlconnector contains also a jar file. So first I tried following the instructions in this link and created seo.jar, but when I try to execute it from the terminal by java -jar seo.jar I get an error :
Error: Could not find file connectionprops.properties
As the screenshot shows, I tried putting connectionprops.properties in main package, but the same problem remains.
Then I tried making a manifest file named manifest.mf with contents :
Main-Class: bin.main.MainClass //also tried Main-Class: MainClass
as the structure of my project is :
seo --> bin --> main --> MainClass.class
I placed the manifest.mf in folder seo and I gave the following command in the terminal :
jar -cvfm seo.jar manifest.mf *
but again when executing it from the terminal by java -jar seo.jar I get an error :
Error: Could not find or load main class bin.main.MainClass
What am I doing wrong? Should I change something in my project structure? Is there a problem that I have other jar files inside my project? How can I create the executable jar and execute it successfully?
The Manifest Main-Class attribute needs to receive the package path to your Main class. It doesn't matter what the structure of the project looks like, what matters is the fully qualified package name that you have inside the src/ folder. So in this case, main.MainClass is what you should write there.
Also, if you receive other errors when trying to read the connectionprops.properties in your program, try to open the file using
someObject.getClass().getResourceAsStream("connectionprops.properties")
bin.main is not a package name. You can't add this to manifest.mf.
You should add the package name only if you have the main class in the package. If your package is default then put only the main class.
Main-Class: MainClass
I have a very basic question about enabling ensime in .java files inside android project (basically its what suppose to be enjine mode as I understood) from emacs.
So I added plugin { id 'org.ensime.gradle' version '0.2.8' } inside my build.gradle in root of my android project, generated .ensime file in project root and after invoking ensime from inside emacs with MainActivity.java file opened - it started ensime server successfully, and changed .java file major mode to ensime Disconnected. But no matter what I do looks like I can not connect to running server.
A also tried to generate new android blank project from scratch with sbt and sbt gen-android and tried to run inside that project root folder sbt ensimeConfig and sbt ensimeConfigProject - no difference, main.scala after enabling ensime-mode in it works great, if I try to enable ensime-mode in some .java file from that project, like MainActivityTest.java - the same as described upper - disconnected and no ensime functionality.
Ok, looks like I found answer - its basically duplication of this. All what needed to do is to add :compile-jars (" [...] /local/share/java/android-sdk-mac_x86/platforms/android-10/android.jar") to .ensime file.
I tried to use some native library and received some Exception with underlying exception UnsatisfiedLinkError:
java.lang.UnsatisfiedLinkError: Couldn't load viblast: findLibrary returned null
I am using Android Studio + gradle.
It looks like android can't find the native library in APK file.
My projects tree:
I tried to put them in "jniLibs" directory, but it doesn't helped me. I think I forget to write something in gradle files, but I can't figure out what.
Create Folder "jniLibs" inside your "src/main/" and put all your .so files inside "src/main/jniLibs" folder. In your screenshot I can't find "jniLibs".
Please follow below steps :
Add the path of your NDK in the local.properties file, located to
the root directory of your project.
add these lines to your app build.grade files :
sourceSets {
main {
jni.srcDirs = ["libs"]
}
}
Remove old .so files from your app.
Go to the directory src/jni directory of your app project and run the command :
PATH_TO_YOUR_NDK/ndk-build
The project is compiling and your get your lib (.so) under the directory libs of your modules.
5.the libraries into your main app should be like below structure.
Please for reference visit this link..!!
Thanks..!!
I get the following error when I try to export my Android project to an APK: Non-translatable resources should only be defined in the base values/ folder. The here is the code it is having an issue with:
<string-array name="about_translators" translatable="false">
This is happening in the array.xml file in the values folder in the res directory. The code it is having an issue with is:
translatable="false"
How do I fix this issue? Any help would be appreciated.
Just found this problem myself, I had strings marked with translatable="false" in a values-es/strings.xml. You have to delete them and leave them only on the values/strings.xml
I am trying to use the libgdx-freetype libraries that come with LibGDX. For the desktop, I simply added libgdx-freetype.jar and libgdx-natives.jar to the /libs folder of the main project (and added to build path) and it just worked. However, when trying to add the same libraries to /libs folder and the libgdx-freetype.so files to the /libs/armeabi and /libs/armeabi-v7a folders, I get the build error:
Description Resource Path Location Type
Native libraries detected in 'gdx-freetype-natives.jar'. See console for more information.
SlotMachine-android Unknown Android Packaging Problem
In the Eclipse console I have:
[2012-12-05 17:38:04 - SlotMachine-android] The library 'gdx-freetype-natives.jar' contains native libraries that will not run on the device.
[2012-12-05 17:38:04 - SlotMachine-android] The following libraries were found:
[2012-12-05 17:38:04 - SlotMachine-android] - libgdx-freetype.so
[2012-12-05 17:38:04 - SlotMachine-android] - libgdx-freetype64.so
Can someone point out what I am doing wrong?
For Android you do not want gdx-freetype-natives.jar included. That is only for your main project. On Android you just need gdx-freetype.jar and the two .so files in your arm folders. The .so files are the natives for Android.