fragment binding generated file - android-studio

I try to add fragment to an old project. I followed the GuessTheWord project of codelads.
In the fragment there is an import of ...databinding...FragmentBindig
..FragmentBinding appears in the java/generated folder.
But in my project I have not such files in the generated folder despite I added buildFeatures {viewBinding true } in the project build.gradle file....
Do you have any suggestions to help to generate these files?
Best regards
Mich

Related

Cannot open a library at 'FileMapping' in Android studio

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'

Android Studio ignores module

I have application module, 4 android lib modules, and 2 java modules. I'm trying to add one more android lib module, but AS ignores it.
New module is created and added to settings.gradle. AS does not add *.iml file to module folder, and .idea/gradle.xml and ./idea/modules.xml files don't contain records about new module. I tried to generate *.iml file by myself, and added records to .idea/ files. It starts working, but then i got message
The modules below are not backed by Gradle anymore. Check those to be
removed from the ide project too
, and *.iml file was removed.
AS 2.2.3, gradle 2.14.1
UPD 1.
The problem was in unexpected place. I tried this solution, because it was very similiar to my problem, tried to delete module and add it again (with new name). But nothing helped. After opening Gradle tab (right top corner), I found that new module was highlighted with dark grey color, right-clicked on it, and saw that "Ignore Gradle project" was checked by default.
I unchecked this item, but after next gradle sync I got above message, and this item was checked again automatically. Also in event log
Unsupported Modules Detected: Compilation is not supported for following modules: modulename. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.
UPD 2.
Seems like https://code.google.com/p/android/issues/detail?id=77983 and https://code.google.com/p/android/issues/detail?id=230550
The solution that helped me:
Close AS
Remove all *.iml files
Remove .idea dir
Remove .gradle dir
Rename project
Open project with AS
android {
...
buildTypes {
...
dexOptions {
preDexLibraries true
}
}
}

I don't have gradle.build, why?

I am using Android-Studio to build my app. In order to add libraries, I need to edit build.gradle file but I don't see it anywhere. Even if I changed files-view from android to project and vice-versa .
Why don't I see/have build.gradle ?
Check in your git repository if it contains the build.gradle files.
If not, you can just add manually to your project.
You should have something like this:
root
|--app
|----build.gradle
|--build.gradle
|--settings.gradle
You can also create a new blank project and copy the build.gradle files into your existing project (of course in the app/build.gradle file you have to change the values and the dependencies).
With huge help from #JuLes (commentting on my question) I figure out how to solve it. Here is what I did:
I totally removed Android-Studio following this guidance, then ...
I installed Gradle from this link, then ...
I re-installed Android-Studio following this link:
I am gussing the main problem was that I didn't installed Gradle manually and hence Android-Studio was using some sort of Gradle-Wrapper to allow the application to run.
Now, finally I can edit build.gradle.
BIG THANKS TO: JuLie

Where to place the 'assets' folder in Android Studio?

I am confused about the assets folder. It doesn't come auto-created in Android Studio, and almost all the forums in which this is discussed talk about Eclipse.
How can the Assets directory be configured in Android Studio?
Since Android Studio uses the new Gradle-based build system, you should be putting assets/ inside of the source sets (e.g., src/main/assets/).
In a typical Android Studio project, you will have an app/ module, with a main/ sourceset (app/src/main/ off of the project root), and so your primary assets would go in app/src/main/assets/. However:
If you need assets specific to a build type, such as debug versus release, you can create sourcesets for those roles (e.g,. app/src/release/assets/)
Your product flavors can also have sourcesets with assets (e.g., app/src/googleplay/assets/)
Your instrumentation tests can have an androidTest sourceset with custom assets (e.g., app/src/androidTest/assets/), though be sure to ask the InstrumentationRegistry for getContext(), not getTargetContext(), to access those assets
Also, a quick reminder: assets are read-only at runtime. Use internal storage, external storage, or the Storage Access Framework for read/write content.
Let Android Studio do it for you.
In Android Studio (1.0 & above), right-click on the folder and navigate to the Assets Folder.
On the next screen just click Finish.
And voila! It will create the assets folder in the main target source set.
Looking inside the .iml file of your project you will see the following line:
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
This means the "assets" folder is already declared for Gradle. You will need to create it under src/main/ (I'm using Android Studio 0.4.2).
Select the app folder and then:
File > New > folder > assets Folder ,
the default location is inside /main folder
First of all the "Assets" folder will not be created automatically with the project. We have to create it.
The location of Assets folder is: App > src > Assets
Please have a look of the simple image below.
Note: For creating assets folder just click on Project => Right click => Select New => Folder => Assets. It will create Assets folder.
It's simple, follow these steps
File > New > Folder > Assets Folder
Note : App must be selected before creating folder.
In android studio you can specify where the source, res, assets folders are located.
for each module/app in the build.gradle file you can add something like:
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
sourceSets {
main {
java.srcDirs = ['src']
assets.srcDirs = ['assets']
res.srcDirs = ['res']
manifest.srcFile 'AndroidManifest.xml'
}
}
}
Simply, double shift then type Assets Folder
choose it to be created in the correct place
Click over main → new -> directory → and type as name "assets"
or... main -> new -> folder -> assets folder (see image)
In Android Studio 4.1.1
Right Click on your module (app for example) -> New -> Folder -> Assets Folder
File > New > folder > assets Folder
Project -> app -> src -> main -> RMB(right mouse button) -> New -> Directory:
Two ways:
Select app/main folder, Right click and select New => Folder => Asset Folder.
It will create 'assets' directory in main.
Select main folder, Right click and select New => Directory
Enter name as 'assets' = > Ok.
If you tried all your bullets in this thread in vain try cleaning your project . In my case it only worked after Projet -> clean
right click on app folder->new->folder->Assets folder->set Target Source set->click on finish button
Put the assets folder in the main/src/assets path.
Src/main/Assets
It might not show on your side bar if the app is selected. Click the drop-down at the top that says android and select packages. you will see it then.
need configure parameter for gradle
i hope is will work
// file: build.gradle
sourceSets {
main {
assets.srcDirs = ['src/main/res/icon/', 'src/main/assets/']
}
}
When upgrading to the release version of Android Studio, you may be automatically switched to the new Android project View (see here for more info). If you swap back to either the Project or Packages view, you should see the standard folder hierarchy of a Gradle-based project. Then refer to CommonsWare's answer for the appropriate location.
In Android Studio, click on the app folder, then the src folder, and then the main folder. Inside the main folder you can add the assets folder.
Step 1 : Go to Files.
Step 2 : Go to Folders.
Step 3 : Create Assets Folder.
In Assets folder just put fonts and use it if needed.
follow these steps
1)file->New->Folder
there are multiple options like
aidl folder
assets folder
jni folder
2) choose options assets folder
3) then there is option to change path of assets folder if you
want to change then check otherwise left that checkbox of cahnge folder location
4) click on finish
Either create a directory under /app/src/main or use studio File-> New -> Folder - > Assets Folder.
In Android Studio right-click Folder in app->src->main then create new DIRECTORY name that assets.
It seems that nobody mentioned this:
You can define it in Project Structure > Project Settings:

How To Add Parse to an Android Studio Project?

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!!

Resources