I should preface this by saying that I don't know much about programming or android app development at all. I am trying to get a program running to control my pool cover automatically. This program is fairly old, which I imagine is the reason for the issues. I have been following this guide to sign and bundle the APK. As soon as I clone the project from github, I am greeted with this:
ERROR: Could not determine the class-path for class com.android.tools.idea.gradle.project.sync.ng.SyncAction.
In addition to this, the "Generate Signed Bundle / APK button" is not available.
From what I can gather, this program uses Gradle 1.10.
Here is the complete output log that I got from android studio
I might have found a solution for your problem but being a project as old as this, you can have problems with library usages.
The reason you're seeing this error is, using info from this answer, because this project was written in Eclipse IDE. The answer says:
when Eclipse export a project to gradle, it use an old gradle plugin version that Android Studio doesn't support.
Following his instructions I changed my Gradle version to 2.3, but Android Studio showed some more errors asking me to upgrade my version to 3.3, as showed here in Project Structure (You can easily access this using Ctrl + Alt + Shift + S).
Notice that Android Studio also asked me to set my gradle plugin version to 2.3 on another error, that I did. You should be aware that I had to change my distributionUrl in gradle-wrapper.properties file, as you can see here
Lastly Android Studio demanded me to change buildToolsVersion because it couldn't make my app with original config. Also what gave me the most trouble was the runProgruard function that Studio said didn't exist. I found the solution in this answer. My app build.gradle ended like this.
PS: At EVERY step of changing this configurations I had to go to menu build->rebuild project and then use the gradle button "try again". Sometimes it might seems it is not working, but with patience you will get there.
Related
A gentleman was kind enough to pass me a link of a repository with bluetooth functionality. I imported it from GitHub. I tried then copying it, but noticed eventually that Android Studio built and organized a different style of directory than that from the github repository. So I deleted the entire directory, and just pasted that of the github depository in.
However, the repository version suffers from the fact that the classes say "Java file outside of source root". Moreover, when I tried to import it, it generates the error "The project is using an incompatible version (AGP 7.3.0) of the Android Gradle plugin. Latest supported version is AGP 7.2.2". I read online I could just update Android Studio instead of downgrade Gradle. When I do the most recent update (I think), Android Studio tells me that the project doesn't use the Gradle build system.
Also, AndroidManifest.xml says that it can't resolve certain activities, such as "MainActivity", which does exist. I think AndroidManifest.xml is in the root folder as it should be.
Any idea what is wrong with my program? At this point, this is just copy-and-pasted from the github Bluetooth Chat program. Is that outdated, etc?
I have spent hours trying to troubleshoot this. Perhaps there is someone with some experience in it.
This question is NOT ABOUT how to debug the javascript-land of an React-Native app. It is about how to debug native libraries (means: JAVA-Code in this case) in the node_modules-folder.
While it is very easy for me to debug native iOS-parts of RN-Applications with XCode, i stumbled upon various issues with Android Studio...
The main thing is, that the node_modules-Folder is not present after importing the project into Studio, why it is not possible to setup breakpoints to debug thru.
Versions:
Android Studio 2.2.2 (most recent version currently)
react-native 0.38.0 (latest version also)
gradle 1.3.1 (preconfigured from react-native init)
also tried with upgrade to gradle 2.2.2
Android SDKs and -Build Tools from up to Version 23 installed including NDK
How I did it / Steps to reproduce
1. create new react native project:
react-native init debugTest
2. install third party library with native code that you want to debug natively
cd debugTest &&
react-native install react-native-sqlite-storage
3. ensure that everything would work on android side:
launch GenyMotion
launch an AVD
run the application with this command in terminal:
react-native run-android
(this will open up packager and everything else that is needed to transfer the js-bundle).
If one wants to omit this step, it is necessary to start the packager manually:
node node_modules/react-native/local-cli/cli.js start
4. launch Android Studio
with the upcoming starter dialog, choose "Import Project"
select the directory "android" of your project and click on "import"
(these steps are taken from official RN-documentation):
If you want to use Android Studio to work on native code, from the
Welcome screen of Android Studio choose "Import project" and select
the android folder of your app.
5. Android Studio asks to update gradle version from pre-configured 1.3.2 to 2.2.2. I have first denied it for the whole workflow, later on i tried it out (both did not differ significantly for me)
6. One have to deactivate Instant Run due to this issue
7. Click on "Run" or "Debug" in the Toolbar of Android Studio
So far everything works fine. I was able to set a breakpoint in MainApplication.java::onCreate and could step into this method then.
But here are the questions:
The node_modules-Folder isn't present in Android Studio and can't be debugged this way. How to achieve that?
Debugging the onCreate-Method and going further down into the Java-Stack, very offen it happened that the "Sourcecode does not match the byte code".
The debugger was hanging somewhere else in comments of source code but not on exactly that line, which was selected to execute.
Android SDKs:
I have installed all SDKs and build tools and NDK and everything else since version 23:
TL;DR:
How to debug native libraries that are present in node_modules-Folder of an react native application with Android Studio, because they are not visible in AS thus no breakpoint could be passed?
UPDATE
Finally i've found out the root cause. For me it wasn't working due to the fact, that the library i wanted to debug, wasn't shown in Android Studio. But this was a mistake by myself because the library wasn't setup correctly, why gradle wasn't able to take notice of it.
So, this question can be used like a blog post how to do it right (and will be sufficient if the 3rd party library works out of the box with "rnpm-link" or "react-native link") [which wasn't the case here in my example]
Have you done rnpm link or react-native link ? Once you do that, there will be additional modules along with the app module, something like this.
You can look at all the java code in the native module and put breakdpoints , debug etc.
Bam.... i can answer my first of the two questions now by myself. Thx to #agent_hunt, who put me into the right direction...
In this example application the bindings wasn't setup correctly. "rnpm link" and the newer one "react-native link", which is part of "react-native install", didn't worked correctly here for the android-part because it is not implemented in the 3rd-party-library right now, that i've used for this example.
That's why gradle didn't take notice of the library. After setting it up correctly, the folder react-native-sqlite-storage appeared in Android Studio and i was able to pass a breakpoint and to stop the execution there.
Nevertheless, debugging this library works fine, but when i wan't to step into lower/"deeper" methods of android SDK, it still has issues to point to the correct line of code ("Sourcecode does not match the byte code")
I have just updated my eclipse through Android SDK Manager, my eclipse pop out and error about the Android SDK.
This Android SDK requires Android Developer Toolkit version 23.0.0 or above.
Current version is 22.6.2.v201403212031-1085508
When I pressed the button "Check for Updates", the result from eclipse is "No Updates were found."
I am sure that my Android SDK should be 23.0.0 above.
All my project listed in the left corner of above picture contains errors.
I have studied this thread and I found that the "Java build path" was "Unable to get system liberary for the project"
The project was not built since its build path is incomplete
Whenever I tried to add the JRE System Library, it failed beacause of "Could not write file: C:\Users\Admin\workspace\ICEAPP(20140819_uc).classpath."
Can anyone give me so help?
Update the ADT-Plugin in eclipse (Help > Check for updates)
You have to remove the whole installation and reinstall everything again. This update seems to fail always. But reinstall works for all of this issues. With the new version 23. It seems there is a big compatibillity problem unsolved yet.
Check for updated fails but eclipse say it need one update. Also SDK Manager seems to be up to date.
Anyway, even if you get ot working, there still are problems for example with implementation of google play service.
Had a lot of issues by myself and others to, but reinstall solved it
New to android dev world and am just getting started here, well trying to anyway. I've downloaded Cordova (2.8, might need to upgrade this), Java JDK (1.7), and the new Android Studio, the Andriod SDK, installed all the 4.x packages with that, and installed ant (1.9.2).
Everything seems to be working as far as that goes. Problem is when I can create a Cordova project, from the command line, load it up in Studio using the import feature, not tweaking anything, just accepting (as I read to do so on some blog out there) and everything seems to load ok and the project is there in Studio, until I try to make it. At this point, I get and error "java: package org.apache.cordova does not exist" This is followed by several other errors, which I feel may be related. I'm not nor am I trying to do anything fancy here, just get the stock up and running.
Anybody know what I'm missing? Do I need to copy a file somewhere or compile something extra? Or am I using the wrong version of something?
Thanks!
I found after hours of searching and trial and error (although mostly errors) I came to find that it was all due to missing the cordova-*.jar file. which needed to be built using the ant jar in the framework folder of my android cordova directory. This step had been majorly left out of a ton of documentation. Once built, I simply copied this into the 'libs' folder of my project and everything loaded up and ran, although I did get a warning about depreciated project from the compiler, creating an ant build and selecting 'external compiler' fixed this warning.
Android Studio uses Gradle project layout. This means main java files should be in /src/main/java. If Cordova generates different structure (it looks like it is old Ant structure) you need to add its source folders to build.gradle
android {
...
sourceSets {
main {
java {
include 'some/wanted/package/**'
include 'another/wanted/package/**'
exclude 'some/unwanted/package/**'
}
}
}
}
Here is where the file sits:
Im new to android development and ive seen some old tutorials before regarding its development on Eclipse. i recently download the new Android Studio to use for the development. However, i found something new called gradle files that are present in the projects folder along with the normal files that used to be in the project.
Everytime i try to run the app i get the following error:
"
Gradle:
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'assemble' not found in root project 'SampleProject'.
* Try:
Run gradle tasks to get a list of available tasks.
"
Could anyone please explain whats the use of gradle? and do i have to use it while developing android apps?
Thank you
Version 0.2.1 of Studio was just released and provides a better error. You should upgrade and see what happens, but it's likely that your project has another problem that should be fixed instead of randomly adding a task that shouldn't be added.
In your top directory file with name build.gradle just put:
task assemble {}
You can see it in known issues here
Get started with gradle here!
Edit: Android Studio 0.2.1 solves this error: http://tools.android.com/recent/androidstudio021released
Android Studio is bleeding edge (not yet beta).
For more stable solution use Eclipse with ADT, e.g. ADT-bundle http://developer.android.com/sdk/index.html
You can develop in Eclipse with ADT and run Gradle build using Nodeclipse/Enide Gradle for Eclipse
(marketplace)
Some screenshots for Gradle for Eclipse: