I'd like to do some experiment with renderscript, so I started with the example shipped with the sdk, but unfortunatly I am not able to compile it.
Is there any extra tool which I might required to compile and build that example, I'd tried to read the doc. but they haven't mentioned anything.
The problem with the Sample project is...
I came to know after building the project eclipse will generate new files in res/raw folder and some files in gen folder, and this files can be used in java files, but this files are not generating. can anyone guide me how to solve this errors.
Thanks,
After about three days of struggling with this, I found that the problem was with the project folder structure, when compiling with gradle. This project shows the correct structure:
https://android.googlesource.com/platform/tools/build/+/11086782041b302109e8349e13b8f9d5e305341d/tests/renderscript/
In short, the .rs files should not be together with the java files, but in a separate folder called 'rs' alongside java and res, with the same inside structure, such as "...\HelloRSProject\HelloRS\src\main\rs\com\example\hellors\mono.rs". Also, be sure to add renderscriptTargetApi to the build.gradle file, like so:
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 16
renderscriptTargetApi = 16
}
}
There is a bug in ADT 22. I've already reported it here(you can find temporary workaround there, too).
Related
It has been a while since I have touched this project. I remember when I created it with the project creation wizard, I was asked for a minimum SDK level (or perhaps a target SDK level). Where do I go in the IDE to view and change this level?
I sort of expected the generated code to contain this information in the AndroidManifest.xml file, where it could be easily changed, however it does not seem to be there.
In general, it is defined in the build.gradle file of the main module(it is named as 'app' if you had not changed) of your project:
{YourProjectName}/app/build.gradle
the value which minSdkVersion stated inside defaultConfig block of android is exactly what you want!
I'm sorry if this has been asked, but I can't seem to find it. Coming from iOS, in Xcode, you can create a new Framework (SDK) project. In Android Studio, I cannot for the life of me figure out how to do that. I can create a Project, and then create a new module, Android Library. Is that the only way to do it? To do it with an accompanying "app"? I couldn't seem to find any other way.
Also a side question, is there a reason why if you name a project my-project, it creates packages as com.mycompany.my_project. Is there any way getting around that besides naming your project as MyProject?
The "Android Library Module" is actually equivalent to Xcode framework concept.
Is that the only way to do it? To do it with an accompanying "app"? I couldn't seem to find any other way.
At the moment, yes, creating a project then creating a new library module and deleting the app module is the easiest way.
This link Android Studio Rename Package tells how to rename the package name.
For how to change application ID, see here: https://developer.android.com/studio/build/application-id
android {
defaultConfig {
applicationId "com.example.mylibary"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
...
}
Also note that, Android Library project does not have applicationId.
I made an androidLibrary project which contains some Volley request classes,
and want to write a unit test for some of these requests.
I have done that like a hundred times, and it works somehow after several tries, but never on the first try.
If I try this via androidStudio
RightClick Project->New->Android Resource Directory
you can choose between sourceSets "main", "debug" and "release". There is no androidTest option.
If I try it manualy, adding the following folders [moduleName]/src/androidTest/res/raw
and put a file inside (lets say image.jpg), I do not get the reference via R.raw.image. In fact I haven't access to R.raw in my Test at all.
I also tried a Build->rebuild project or Build->clean without success.
In other projects I have a my.app.namespace.R along a my.app.namespace.test.R which holds all test resources.
So my question is:
What do I need to do in order to add a res folder to my androidTest, which is accessible via R.[folder].[resId]?
Am I missing a crucial step after adding the files (i.e. telling gradle explicitly about it)?
Because adding a tag like this in my build.gradle also doesn't seem to make any difference:
android {
sourceSets {
androidTest {
java.srcDirs = ['src/androidTest/java']
res.srcDirs = ['src/androidTest/res']
}
}
}
If it matters I am using:
Android Studio 3.1.2
gradle-wrapper 4.4
minSdkVersion 19
targetSdkVersion 27
I figured out what is going on with the help of the update of Michael Krussel Answer:
Android Studio is not compiling the my.app.namespace.test package automatically. All you need to do is run the Test the first time, ignoring the errors AndroidStudio might present.
After the first run you got access to the whole test namespace (including the *.test.R class)
No additional gradle config (like sourceSets from above) are necessary!
I've recently just imported my eclipse project into Android Studio, I haven't convert it into gradle yet. So some forum that offers me solution from gradle is not working. My problem is I have 2 application, where both has some slight difference. I want to use the same project when I deploy the application. I've tried to change the project name but that doesn't help. The moment the new application is installed, the previous version is overwritten. I thought of making some changes to the Manifest file(not sure if this is the right thing to do) but in android studio, I can't seem to locate where the file is. Please help.
Regards,
Dexter
Your application needs to have a different package name for it to be treated as a different app.
So instead of
com.yourcompany.apps.yourapp
You write
com.yourcompany.apps.yourapp1 and
com.yourcompany.apps.yourapp2
You can do that in your AndroidManifest.XML in the manifest tag
package="com.yourcompany.apps.yourapp1"
Also, instead of 2 separate apps, try seeing if you can solve this using Build variants and product flavors.
Use flavors on your build.gradle
productFlavors {
flavorName {
minSdkVersion 19
applicationId 'you.package.name'
targetSdkVersion 23
versionCode 1
versionName 'version_name'
}
}
Also you can modify a file with different changes by just adding a source folder for the flavor.
app
|--src
|--main
|--flavorName
I want to import Android project in Android Studio and this is where the problem begins:
1) If I set Gradle home and click OK, I get the info:
2) And secondly, if I try to run project I get the message:
Trying both ways result in displaying messages above.
I have GRADLE_HOME, JAVA_HOME set correctly and ANDROID_HOME points to "sdk" directory in android-studio directory.
Much appreciation for answer with the solution.
Point to the folder <gradle root folder>/libexec. Things should start working.
Ok, I missed to download some build tools for specified android version, arrgh.. Anyway, thank you for your interest and the answers. I am quite new to gradle and Android studio. I have been developing android apps with intellij so far.
That worked for me:
1. Open Android SDK Manager.
2. Make sure that "Build tools ..." libraries are downloaded and it should work properly.
I'm going to respond to this cause I had a ton of problems.
what I did was in linux
in terminal
type "which gradle"
if there is a symlink follow this until you see where your gradle is located.
mine was located in the following.
/usr/lib/gradle/4.2/bin/gradle
so now just use
/usr/lib/gradle/4.2/lib is what you want to put in intelliJ
Try to use default gradle wrapper. Android studio will do everything correctly.
I had the same problem (Cause: unexpected end of block data) while importing a project, and resolved by setting ANDROID_HOME. export ANDROID_HOME=/android_sdk_root_dir
I had a "Cause: unexpected end of block data" as well. What I did was installing the right SDK version for Android. Check your build.gradle file.
In my case I needed API level 18:
android {
compileSdkVersion 18
buildToolsVersion "18.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
versionCode 1
}
...
}
I was facing the same issue, I went to http://gradle.org/gradle-download/ and downloaded the latest gradle. I then linked my project to the path where i had saved the gradle, and everything worked