Ensime for .java files inside android project - java

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.

Related

androiddeployqt.exe now crashes when migrating from Qt5 to Qt6

I am developing an android application using Qt.
I decided to migrate from Qt5 to Qt6 for the convenience of the project, but androiddeployqt.exe, a tool for deploying to Android, started to crash after migrating to Qt6.
"C:\Qt\6.2.4\mingw_64\bin\androiddeployqt.exe" --input ~/android-{packageName}-deployment-settings.json --output ~/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-build --android- platform android-30 --jdk "C:/Program Files/Android/Android Studio/jre" --verbose --gradle
Generating Android Packages
Input file: ~/src/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-{packageName}-deployment-settings.json
Output directory: ~/src/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-build/
Application binary: building
Android build platform: android-30
Install to device: No
Delete missing files ~/depend_android ~/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-build/{packageName}
Delete missing files ~/depend_android ~/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-build/{packageName}
Delete missing files ~/depend_android ~/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-build/{packageName}
Delete missing files ~/depend_android ~/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-build/{packageName}
Delete missing files ~/depend_android ~/build-Android_Qt_6_2_4_Clang_arm64_v8a/android-build/{packageName}
...
As shown in the above log, the same log output is looped infinitely and eventually crashes
I checked the source code under the Qt installation directory to solve the problem. (C:\Qt\6.2.4\Src\qtbase\src\tools\androiddeployqt\main.cpp)
The cause of the loop seems to be that the parent directory of the specified Path is passed instead of the directory of the Path specified by the argument to deleteMissingFiles() of main.cpp L400.
As of Qt5, the specified Path was passed instead of the parent directory's Path. At least that's what the code in androiddeployqt/main.cpp looks like.
Qt6 androiddeploy qt/main.cpp L400
deleteMissingFiles(options, src.absoluteDir(), dst.absoluteDir());
Qt5 androiddeploy qt/main.cpp L386
deleteMissingFiles(options, src.absoluteFilePath(), dst.absoluteFilePath());
I would like to ask people who are developing using Qt6 and androiddeployqt.exe. How do you work around this issue?

Playframework messages loading issue

I have a play framework (2.2.3) project which also uses maven. One of the dependencies in my project is org.apache.wss4j.wss4j-ws-security-common-2.1.4.jar. This JAR has a messages folder in classpath. On starting play I get the following error (I am just pasting a few lines here)
Oops, cannot start the server.
MainException: class java.lang.NullPointerException(null)
class java.lang.NullPointerException(null)
java.io.FilterInputStream.read(FilterInputStream.java:133)
play.api.i18n.Messages$MessagesParser.parse(Messages.scala:216)
If I remove the messages folder from this JAR, play starts normally. I assume that Play tries to load all messages in the classpath and expects them to be files - it breaks because the messages in the WSS4J jar is a folder.
How can I resolve this error?
The way I solved this problem was changing the name to the folder that contains the "wss4j_errors.properties" file.
In code, edit line 42 at src/main/java/org/apache/wss4j/common/crypto/WSS4JResourceBundle.java
Run the tests, compile and try the new jar.
Not the answer I would like, but it works.

Where is the R.java file in Android Studio?

Where is the R.java file in Android Studio? Can someone please help with this? I already tried google for the answer but can't find any solution.
Based on the new stable release of Android Studio (3.6) we have:
So, now to find your generated resource classes you need the following steps:
1) Open your project.
2) Go to your module build path.
3) Open the outputs/apk/debug/app-name-debug.apk file.
4) Choose your classes.dex file.
5) Look at the down placed area and go to your full package path.
6) You can see all bytecoded resource classes. So, scroll down to what you are looking for.
7) Expand the resource class you need to proceed (for example, let it be R.id)
8) Go to you id's.
That's it.
UPDATE:
If you would like to see actual id integer number you should follows steps below:
1) By (7) Go to the resource class you need to proceed and right click to show the context menu
2) Choose "Show Bytecode" to see the flexible dialog "DEX Byte Code for R$id", for example, for id class
3) Scroll down to the actual id to look its number
Although the current Android Gradle Plugin doesn't generate a R.java anymore you can still inspect the corresponding class file (see Sergey V.`s answer).
However, if you (like probably in most cases) just want to look up the generated IDs for your resources, there is an easier way:
In the project pane on the left hand side switch from Android to Project view using the drop-down at the top. Then navigate to app/build/intermediates/runtime_symbol_list/<insert build type here>/R.txt. This file lists all IDs generated by AGP during the build process.
I use Android Studio 3.3.2
\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\android\support\constraint\R.java
As noted above, "The new Android Gradle Plugin generates the corresponding bytecode directly and does not make the intermediate R.java file".
Using the ubuntudroid solution you can find an id also this way. Find R.txt and copy absolute path. Project > app > build > intermediates > runtime_symbol_list > debug > R.txt. Then right click and select Copy Path..., 1. Absolute Path Ctrl+Shift+C.
This way you will obtain a path to R.txt, for instance, "C:\Users\user\AndroidStudioProjects\your_project\app\build\intermediates\runtime_symbol_list\debug\R.txt". Copy the path without R.txt to a text file for future references, for example, with Notepad++.
Press Ctrl+Shift+F to find in directory. Insert an id and the path.
== Old answer ==
Change a project view from Android to Project or Project Files. Find one of these two files.
Then you can revert back to Android view.
I use Android Studio 2.3.3. The R.java file is shown in the picture above.
In the left upper side, there is a select list. Select the [project] option so that you can see all the folders and files.
R.java is the generated file by ADT or Android studio. It will be located under app\build\generated\source\r directory.
./app/build/generated/source/r/debug/android/support/v7/appcompat/R.java
./app/build/generated/source/r/debug/your/packagename/name/R.java
I am using Android Studio 2.2.3 , the R.java file is shown in the picture below.
Goto in the left upper side there is a selecting list ,
select [package]
Open "App Folder"
com.example.saeedanwar.myapplication;
r
In my project in Android Studio 4.1
R.jar that you can actually unzip resides in app build folder, as follows:
jar -xf R.jar
Once the jar is unpacked you can find R.java inside of app package:
If you're using Mac or Linux, try the following command line on your terminal:
find . -name "R.*"
It will print something like:
./app/build/intermediaries/runtime_symbol_list/debug/R.txt
./app/build/intermediaries/compile_and_runtime_not_namespaced_r_class_jar/debug/R.jar
It is inside app\build\generated\source\r folder
Project/app/build/generated/source/r/debug/com.android.'projectname'/R.java
--The R.Java that contains your xml layouts and views id's in Android Studio 3.5.3 -- Project/app/build/generated/not_namespaced_r_class_sources/debug/r/com/"your package"/R.java
This answer will be in a constant state of flux until Android standardize a method of matching their annoying decimal/hexadecimal id references to a tangible resource such as my_layout.xml.
For Android Studio Dolphin | 2021.3.1 Patch 1 have a look at this file:
/project/package/build/intermediates/stable_resource_ids_file/debug/stableIds.txt
It is produced by RUN (not just BUILD). Sample:
layout/mtrl_picker_header_fullscreen = 0x7f0d00de
string/cancel = 0x7f1101f0
style/ThemeOverlay.MaterialComponents.MaterialCalendar = 0x7f1202f3
id/gpxBtn = 0x7f0a0346

IntelliJ- Android Schema URI not registered

I'm programming an Android app that uses Gradle. However, in the .xml files and Android Manifest, the URL for Android Schemas are "Not registered".
This problem has been a nuisance and have spent hours trying to get it fixed. I have looked through:
1: Intellij Android project schema URI not registered?
2: If I change an external library: AndroidManifest, cannot parse file
I cannot just create a new project because this application is not only developed only by me but a small team. The code is also on GitHub as well. Secondly, even if I try to create a new project, the Schemas are still not registered.
Eclipse is not an option because they do not officially support Gradle integration. (unless you have found a Gradle plugin that is SPECIFIC to android applications). I also have installed Android Studio, but I still get the same errors, if not more errors.
Edit: I am currently using Intelli-J community edition
I had almost the same problem, 2 different flavors and that URI error in the xml files inside one of the flavors. I've solved by placing a copy of the Android Manifest inside the folder of the flavor that was giving me trouble, build project and error gone
For me the only thing worked was add mock Activity with right click on the Flavour package, choose "new->activity>empty activity", choose the fit source set and package name in the dialog, and after the Activity created the problem solved. I deleted the mock activity later and it not brought any problem.
Combining both Hernan Romero's answer and yshahak's answer, create an Android Manifest file inside each flavor's root folder.
For example, if you have a flavor called "pro", right-click on the pro folder then choose new * other * Android Manifest File.
(I did it the "long way": for each flavor, I set that flavor to be the active variant and then created a dummy empty activity with no layout file. I then removed the activity and unneeded xmlns: from the manifest and then deleted the activity and now-empty java folder in the flavor's folder. Rinse-repeat for the other flavor(s). That left me with an almost empty manifest, for each flavor, as follows:)
My "dummy" AndroidManifest.xml file in each flavor contains only:
<manifest>
<application/>
</manifest>

Error adding libGdx freetype libraries to Android project

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.

Categories

Resources