Compiling greenDAO source - greendao

When I do a fresh git clone of the greenDAO repo, import the project with Android Studio, and try to compile, references to all the Android objects throw Unresolved Symbol/Method errors. Similarly, the Android specific import statements are also unresolved.
I've gotten as far as realizing that the build.gradle files don't call apply plugin: 'android', but instead lists dependencies like:
dependencies {
provided 'com.google.android:android:4.1.1.4'
provided 'com.google.android:android-test:4.1.1.4'
provided 'com.google.android:annotations:4.1.1.4'
provided 'com.google.android:support-v4:r7'
provided 'com.google.android:support-v4:r7'
...
}
I've used the SDK manager to make sure I have all the files for API v4.1 installed. I also know how to use greenDAO by using the Maven repos and/or importing JARs. My problem is specific to building from source.
Update 1: As stated, when using provided, none of the Android files are found.
I don't have enough reputation to post images, but you can find a screenshot here.

Related

Flutter plugin that uses .aar modules builds and runs fine in the example app but fails to build in a different app

I've written a Flutter plugin to use an SDK that requires the inclusion of some .aar modules. It builds and runs perfectly in the example app for the plugin, but when I import the plugin in a different app and try to build it, the build immediately fails with a message saying that one of the .aar modules could not be found in the plugin. This makes no sense because the module is definitely there - the platform channels to use the SDK would fail in the example app if the module wasn't there.
Why would the example app build and run without any problems but a different app won't? The only thing I can think of is that I import the plugin from path in my pubspec but it seems unlikely to me that this is the culprit.
Any advice or assistance here would be appreciated. TIA!
I got it!!!!
The answer is as found here: How to add .aar dependency in library module?
The way this adapts to a Flutter plugin is as follows:
Add a libs folder at the root of the android project in the plugin. Add the .aar files there.
In the plugin's build.gradle file, update rootProject.allProjects to look as follows:
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
dirs project(':your_plugin_name_here').file('libs')
}
}
}
Still in the same build.gradle, add your .aar file(s) as dependencies as follows:
implementation(name:'aar_name_here', ext:'aar')
In the Flutter app that you want to use the plugin for, open the app-level build.gradle file and add the plugin itself as a dependency, like so:
android {
...
dependencies {
implementation project(':your_flutter_plugin');
}
}
In the settings.gradle file for the app that us using the plugin, change
include ':app'
to
include ':app', ':your_flutter_plugin'
And this should do it!!

error: unresolved reference: mongodb in Kotlin

I am new to Kotlin. I want to perform basic CRUD operations with Mongo DB and I get the following error:
error: unresolved reference: mongodb
for this line of code:
import com.mongodb.BasicDBObject
I have added the following dependency in the build of the module in Android Studio (Intellij IDE).
implementation 'org.mongodb:mongodb-driver-sync:3.11.0'
What am I missing?
EDIT
This is the project hierarchy. I work with DBOps.kts
I think you are using legacy code.
Here is the correct one for that.
dependencies {
compile 'org.mongodb:mongo-java-driver:2.13.3'
}
Reference : https://mongodb.github.io/mongo-java-driver/2.13/getting-started/installation-guide/
EDIT
I have tried myself, and it works, so I guess there is another issue.
After importing library via Gradle, you could check it is imported correctly from Project -> External Libraries(Check below image)
If you cannot see the MongoDB library from there, there is a possibility that IDE has some problems. So I would recommend reset caches(File -> Invalidate Caches / Restart), clean build, and rebuild the project.

Building library project in Android Studio that has been imported from Eclipse

I have an Android library project in Eclipse that I am trying to build with Android Studio so I can generate an .aar file for my users.
The project seems to have been imported cleanly into Android Studio using the "Import Project" option in the welcome screen.
How do I now build the module? The instructions on the dev site say that I need to change:
apply plugin: 'android'
to
apply plugin: 'android-studio'
However my build.gradle file doesn't have that line (I would have assumed that the importer would have added it(?)).
If I insert the line apply plugin: 'android-library', and try to 'Sync Project with Gradle Files', I get the error:
Gradle 'MyProject' project refresh failed
Error:C:\Users\Fred\AndroidStudioProjects\MyProject\src\main\AndroidManifest.xml
(The system cannot find the path specified)
The same happens if I try to make the project anyway.
Here's what my build.gradle looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
apply plugin: 'android-library'
My searches to find a solution have failed. Anyone know what is going on?
I'm using the latest Android Studio (0.5.8)
Don't put the apply plugin: 'android-library' statement in the top-level build file. You should find an apply plugin statement in your module-level build file, and you can modify it there as necessary.
Okay. After some head scratching and more searching, I resolved all my problems I think. For the record:
I think my first import broke somehow. Partly because of the problem highlighted by Scott Barta and possibly because my project directory had spaces in it? Not totally sure.
A later import went more smoothly and I was able to sync and build without errors. However, apart from the build output in the Gradle Console, there was no evidence anything had actually happned. The artifact (ie. the .aar file) doesn't show up in the UI.
After finding this question: How to export library to Jar in Android Studio? I realised that the aar file is in fact built. It is just hidden from you. You have to root around in the file system to find the .aar. It is in:
<Library module>/build/libs/
Something that the docs don't tell you anywhere. Sigh.
Hope this helps someone else..

Getting "Unable to execute dex: Multiple dex files define" error when trying to run main project which is using other library project

I am trying use androidVNC open source project as a Library Project in my MainProject. androidVNC has also used ZoomerWithKeys library project. I want start a activity of androidVNC library project in my MainProject by clicking on a Button.
I have done all the basic things like to define all the activity of library project in Manifest of main Project.
The problem is that i am getting following error when trying to running my MainProject -
Dex Loader] Unable to execute dex: Multiple dex files define Lcom/antlersoft/android/zoomer/R$drawable;
[2013-05-16 15:44:03 - OtherProj] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/antlersoft/android/zoomer/R$drawable;
Thanks in advance.
I resolve this by doing following steps:
Go to bin folder of you app and see which libraries are duplicated(in mine I had 2 supportv4****)
Hold your mouse on them and see where they compile from, keep in mind that you should keep the most important one, so if you are using appcompat and facebookSDK, you should keep that library which comes from appcompat
Go to the properties of the project of the other library (e.g facebookSDK) -> Java build path -> Libraries and delete the dependency in which the buggy lib come from(in mine, supportV4 nested in Android Private Libraries, so I delete it),
Also do it from a file manager, go to our project folder/libs and delete that buggy library if it's not cleaned by default
In that window, after deleting, choose Add Jars... and select the library of the other project(in mine, I choose SupportV4 from appcompat)
Clean you workspace, restart Eclipse
The problem should have gone, these steps work more than fine for me
1).did you added your lib project to the main project?? Make sure..
2).also add the project to your lib project by doing this process--
In the lib project-->>right click on project-->>java build path-->>on the project tab-->>add your main project.
Now build your project..hopefully it will help you.
EDITED::
3). Go to the project properties..edit this(can give some space) and then save..clean project...then build..
I tackled with this kind error in Android Studio.
In my case my main project was using two my own lib. But beside this those two libs were using the same library as external included
compile files('lib/external-lib.jar')
I solved it by doing following in my both own libs.
1)Removing old compile files('lib/external-lib.jar' ) from build.gradle and deleting old external_lib.jar from lib folder.
2)Adding library from jcenter() two my own libs
compile 'external.lib:1.9.2'
3)Rebuild.
Then rebuild and run main project
Then problem has disappeared.

Android SDK tools rev 19: Issue with external jar files

I know this question was asked a couple of times on stackoverflow - but I still face some problems trying to add an additional jar file to an existing android project - using android sdk tools rev. 19.
Summary:
I use eclipse Version: 3.6.2
The project compiled and the artefacts worked with android sdk tools rev. 14/any android >2.2 (>= API 8)
The project does compile with sdk tools rev. 19/any android >2.2 BUT the artifacts do not contain the jars defined within the classpath - so I keep getting java.lang.NoClassDefFoundError exceptions
I tried to add "jar.libs.dir=lib" to my project.properties - since lib contains all the jars without any positive effect.
I also tried to create a new dummy project adding jars as I always did (all jars added to a lib folder within the project, right click on the jar > add to build path)
I tried to add the jars using import
Thank you for your help.
Rename your "lib" folder to "libs".