I am trying add a .so files to a dlib libary in android studio. I have followed the following steps
Migrate from ndkCompile
If you're using the deprecated ndkCompile, you should migrate to using either CMake or ndk-build. Because ndkCompile generates an intermediate Android.mk file for you, migrating to ndk-build may be a simpler choice.
To migrate from ndkCompile to ndk-build, proceed as follows:
Compile your project with ndkCompile at least once by selecting Build > Make Project. This generates the Android.mk file for you.
Locate the auto-generated Android.mk file by navigating to project-root/module-root/build/intermediates/ndk/debug/Android.mk.
Relocate the Android.mk file to some other directory, such as the same directory as your module-level build.gradle file. This makes sure that Gradle doesn't delete the script file when running the clean task.
Open the Android.mk file and edit any paths in the script such that they are relative to the current location of the script file.
Link Gradle to the Android.mk file .
Disable ndkCompile by opening the build.properties file and removing the following line:
// Remove this line
android.useDeprecatedNdk = true
Apply your changes by clicking Sync Project in the toolbar.
However I am getting this error saying the project cant configure.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':dlib'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:94)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(Li
Caused by: java.lang.NullPointerException
Any help much appreciated.
Related
Cannot open a library at 'FileMapping(from=/home/alamin/Database/Automail/app/libs/additional.jar, to=/home/alamin/.gradle/caches/transforms-2/files-2.1/5c80954b8617a057a166d4547256bdee/jetified-additional.jar)'
I have added 'additional.jar' in libs folder and have added this dependency in build.gradle
implementation files('libs/additional.jar')
I have also try this solution form this question:
Cannot open a library at 'FileMapping'
You've just deleted the jetified-additional.jar file from the lib folder directly. Now you've to remove the jetified-additional.jar file from the dependencies of the program too. So go on File - Project structure - Dependencies - under app find the "jetified-additional.jar" and remove it from here. Now again run the project the error will not be there because you've also removed the jetified-additional.jar from the file tree structure of your project.
Hope this will help!!! Happy coding :)
I also answered this here Cannot open a library at 'FileMapping'
I have converted one of our Android projects from the old Groovy settings.gradle and build.gradle files to the new Kotlin DSL, i. e. settings.gradle.kts and build.gradle.kts.
While "it works on my machine" - in particular: the original project I converted from Groovy to Kotlin works fine in its original directory - all my co-workers are unable to open the project when they clone the repo. Importantly, neither can I open the project myself (with the same AS installation on the same machine) when I clone the repo to some other directory. So, I suspect there is some additional detail missing in some configuration file but I cannot seem to figure out which...
Details:
When I just use File > Open... and then select the project folder, I only get the error message "The project 'xxx' is not a Gradle-based project"
When I instead go through Import Project (Gradle, Eclipse ADT, etc.) and then select Import project from external model and Android Gradle Android Studio will create an empty build.gradle file and fail with the error message "ERROR: Plugin with id 'com.android.library' not found." Deleting the build.gradle just goes back to the error message I described in the first bullet point.
I am aware of this Github issue, which seems to describe the same problem, but it's been very quiet and I thought someone around here must have figured out a solution to this...
Oh, command line builds work everywhere - this is purely an Android Studio problem.
UPDATE: When I copy the whole project to a new folder (instead of cloning the repository) I can open it without any problems. So, am I correct in assuming that there must be something inside the folder - but not in Git - that makes it work?
I was able to 'fix' it by deleting the .idea directory and reopening the project. The .idea directory is usually not committed in git but I guess copying the directory invalidates the directory structures in the files within the .idea directory.
The whole bug is easily reproducible when you click on File > Re-import Gradle project.
#Boni2k answer does not work for me.
I have to rename the root build.gradle.kts back to build.gradle, fix the syntax error, sync the project (which works fine immediately), and rename the file back to build.gradle.kts. Then the error is gone and I can sync the project successfully.
What I did to raise the error was that I moved the project to a different folder, and rename the project.
For a helping lib I use, I recently get:
Error:Unable to resolve dependency for ':app#debug/compileClasspath':
Failed to transform file 'mylib-release.aar' to match attributes
{artifactType=android-exploded-aar} using transform
ExtractAarTransform
and then on gradle console:
Could not resolve all files for configuration
':demo:debugCompileClasspath'.
Failed to transform file 'mylib-release.aar' to match attributes {artifactType=android-exploded-aar} using transform
ExtractAarTransform
java.io.FileNotFoundException: mylib-release.aar (Datei oder Verzeichnis nicht gefunden)
It was working last week, unfortunately I forgot what changed
In my case it was the missing .aar file (or files, depending on how many buildtypes you have), as #JBTPublic pointed out.
So how did I fix it? Well, you need to generate it by yourself. At least for me, Android Studio doesn't generate it by itself. I had imported an Android library onto my project, and it was working perfectly well in a Linux environment. But I forgot that I needed to generate the AAR file before running my Android app.
To generate the AAR file, if you have an Android Library as a dependency for your project, you need to:
Open the your-android-library/build.gradle
In the Android Studio menu, go to Build -> Make Module 'your-android-library'
Once the Make is done (you'll see a Build SUCCESSFUL message), then you are all set up to Run your Android app as you normally do.
Hint: Add this info into your Readme file, in order for you not to
forget once you change environment, like I did just last night before
going for a trip.
In my case this error was due to that .aar was missing so in your case check that your lib mylib-release.aar exists and is found in the debug compileClasspath.
Well, you need to generate .AAR file by yourself.
go to root project folder -> your proj -> build -> outputs -> aar -> delete folder or content
go to gradle tools window (usually top right corner of android studio) and get execute task build
your proj-lib-aar -> your proj -> Tasks -> build (double click)
I'm trying to use mp4parser library in my project. My android studio version is 1.0.2. Here's what I've done so far:
I've downloaded mp4parser zipfile from the link: https://github.com/sannies/mp4parser
I've extracted the zip file to MyProjectName/app/libraries
Renamed the folder to mp4parser
Add this line of code to settings.gradle file:
include ':app:libraries:mp4parser'
Add this line of code to build.gradle (in dependencies block):
compile project('libraries:mp4parser')
Now I want to sync the project with gradle files. This error pops up:
Error:Configuration with name 'default' not found.
I don't have this problem with other libraries. Seems that its only mp4parser that I have problem with. How can I fix this?
If you're including the library as source, the best thing to do is to unpack it somewhere and import it as a module.
The error you're getting is cryptic but it means that the build system is looking for a build.gradle file at that location and not finding it (or it doesn't see an apply plugin statement in the file telling it what to do). I'm assuming that the library you're trying to use doesn't have a Gradle build script.
If you import the library using the Android Studio UI, a build script will be generated for the module and you should be good to go.
I'm trying to use the Parse library in Android Studio. I have used the basic example on their website and added the jar to the libs folder as well as added as a global library. Nothing seems to be working without errors:
Gradle: package com.parse does not exist
Gradle: package com.parse does not exist
Gradle: package com.parse does not exist
Gradle: cannot find symbol variable Parse
Gradle: cannot find symbol variable ParseAnalytics
Gradle: cannot find symbol class ParseObject
Gradle: cannot find symbol class ParseObject
Android Studio gives no errors in the code.
I encountered the same problem too and here's what I did:
I placed the entire Parse-1.2.5 in the libs folder (I didn't have to create the folder as Parse's quickstart said).
Open the build.grade file. There are two of them - open the one that's at the same level as the src folder
You'll see two instances of "dependencies". Add the following to the "dependencies" that is NOT nested under "buildscript":
compile files('libs/Parse-1.2.5/Parse-1.2.5.jar')
If that still doesn't work, try right clicking the Parse-1.2.5.jar file and select "Add to Project Library"
Hope that helps!
As of version 1.10.0 the Parse SDK is open source and available on Maven, so now you can just put this in gradle:
compile 'com.parse:parse-android:1.10.0'
Just replace 1.10.0 with whatever the newest verison is at the time you read this.
Alternatively, if you like living on the edge, you can tell gradle to auto-update:
compile 'com.parse:parse-android:1.+'
EDIT: On 1/28/16 Facebook announced that they are retiring the Parse service, so if you are starting a new project I would urge you to consider using a different service.
The problem is that gradle doesnt do a proper rebuild and somehow still reads a cached version of the old build script. Add the libs as per above reply then open a terminal and do a gradle clean. If you are running on windows (or any platform for that matter) I suggest you do a quick internet search on "intellij clean" to see what it does and then simply do a manual clean by deleting the appropriate folder. This should do the trick!
edit: before manually deleting the appropriate folders/caches you can also first try clicking on file -> invalidate caches. If this still doesnt work manually delete all the appropriate folders and caches
1) I unzip the folder into the libs folder:
YourProject/app/libs/Parse-1.9.2/ <<< here all the jar files.
2) and then in the dependencies section from your build.gradle, I set:
dependencies {
...
// Parse 1.9.2
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs/Parse-1.9.2', include: 'Parse-*.jar')
...
}
I set the specific folder where the jars are contained dir: 'libs/Parse-1.9.2'
Hope it helps!
In your app gradle add below code
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}
In AndroidManifest.xml file add below permission
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
In your Application class inside onCreate() method add below code
Parse.initialize(this, "application_id", "client_key");
ParseInstallation.getCurrentInstallation().saveInBackground();
then run. Hope this works, for more info https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing
Place the contents of the Parse-1.. folder in to your libs directory ... not the Parse-1.. folder itself. That worked for me.
donwload parse SDK for android and follow instruction given on below mentioned link:
https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing
Add the SDK to your app in Android Studio
Add the following to your build.gradle
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}
and then
Add the following to your Application#onCreate():
Parse.initialize(new Parse.Configuration.Builder(myContext)
.applicationId("YOUR_APP_ID")
.server("http://YOUR_PARSE_SERVER:1337/parse")
...
.build()
);
Your app must request the INTERNET and ACCESS_NETWORK_STATE permissions, if it isn't doing so already. Add the following lines inside the tag in your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Compile and run!
After installing the SDK, copy and paste this code into your app, for example in your Activity#onCreate():
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
You will also have to add an import statement at the top of your file:
import com.parse.ParseObject;
Run your app. A new object of class TestObject will be sent to the Parse Server and saved.
Unzip the Parse.zip file
Go to Android Studio. Change Android to Project (top left corner).
Expand the folders and find "libs".
Copy the "parse" folder and paste it in the "libs".
Now, under the "src" open build.gradle
Paste the following under dependencies-
compile files('libs/Parse-1.9.4/Parse-1.9.4.jar')
compile files('libs/Parse-1.9.4/bolts-android-1.2.0.jar')
(give your Parse version name)
Done. You gotta ready to go!!