RenderScript BCC Compiler failed while running BasicRenderScriptSample - android

I have seen the question already asked in Can't find ScriptC_saturation in BasicRenderScript Sample
but as I am new in RenderScript, I can make it out they have already done much, so I cannot find the question as low level as I am asking:
I am using Eclipse Juno and have imported the BasicRenderScriptSample.
I am using the android.support.v8.renderscript (
(eclipse) project properties:
renderscript.target=18
renderscript.support.mode=true
sdk.buildtools=19.0.3
When I was not sure why the ScriptC_saturation is not auto generated, I was stuck till I followed the answer below, and copied the .rc file in the necessary folder, and everything compiled well.
Update:
Setup the necessary gradle properties as below (using jcenter rather than mavencentral):
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.android.basicrenderscript"
minSdkVersion 'L'
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:18.0.+"
}
On Compilation I get this error in emulator and device all alike (from eclipse as well):
RenderScript﹕ bcc compiler terminated unexpectedly
RenderScript﹕ bcc: FAILS to prepare executable for 'saturation'
What could be the reason?
update 2: My Eclipse version of this project, somehow ran after series of cleaning, on the device (less than L) properly, but Gradle version project runs with THE error everywhere.

Don't put the .rs file in your res/ folders. It is a source file, not a resource. It dynamically creates .bc files which do end up automatically in your res/raw folder.

Related

Using data-binding in android error: package *.*.databinding does not exist

I'm trying to implement data-binding in android app. This is the link I'm following to set it up. Even after doing all the necessary implements, I'm getting the following error in gradle-build:
error: package com.example.satpracticeapp.databinding does not exist.
(This package is what I'm importing in my MainActivity.java file)
I tried this (the data-binding compiler), but it didn't work.
The problem is I've already successfully tried a hello-world app using data-binding and it works. But, when I try to implement it in an app I made a few weeks ago, I get the error I mentioned above. Searching for the solutions, I copy-pasted the gradle files from my successful hello world app to my old app - that too didn't work out.
Here is my app level build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.satpracticeapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.0'
}
And here's the buildscript of the project level build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
Here are the links to the minimal version of the three files (if it's needed)
MainActivity.java
ViewModel.java
activity_main.xml
After much hair-pulling, I couldn't figure out the solution and getting the same build error again and again.
So, as a temporary solution, I'm trying to copy-paste my classes and layouts in the working hello world project. What am I missing?
EDIT:
After a few hours of pointless searching, I went back to my code. Checked it word by word and found a typing mistake at the name of a binding variable in the xml file.
Everything works fine now!
I had the same issue, turned out to be a duplicate symbol declaration in one of my *.java classes. It's shown in the Gradle console but it was kinda hidden among the databinding errors. i had about 72 data binding errors and this duplicate symbol error was in the middle so it's easy to miss.

Android Studio Build Failed - Compiling local project errors

A few months ago, I decided to take some custom methods and classes that I was using in more than one project and put them in their own project called "FarmSoftLibraries" that all of my projects could reference. This allowed me to make changes or additions once. It has been working very well up until yesterday (8/23/2015) when i started getting an odd error on a new method that Gradle could not find. However Android Studio had no problem finding this method. See: https://stackoverflow.com/questions/32167734/cannot-find-symbol-method-for-custom-static-class-method. However older, non-new methods continued to work.
Today the entire build system stopped working and I'm getting hundreds of Gradle errors saying that packages and methods in FarmSoftLibraries do not exist. Still, Android Studio has no problem locating these.
D:\Scott\Android\Studio\SpellingTutor\app\src\main\java\com\farmsoft\spellingtutor\Learn.java:12: error: package com.farmsoft.farmsoftlibraries.Utils does not exist
import com.farmsoft.farmsoftlibraries.Utils.FarmUtils;
^
D:\Scott\Android\Studio\SpellingTutor\app\src\main\java\com\farmsoft\spellingtutor\Learn.java:14: error: package com.farmsoft.farmsoftlibraries.Utils does not exist
import com.farmsoft.farmsoftlibraries.Utils.Logg;
^
D:\Scott\Android\Studio\SpellingTutor\app\src\main\java\com\farmsoft\spellingtutor\utils\KeyValueDB.java:6: error: package com.farmsoft.farmsoftlibraries.Utils does not exist
import com.farmsoft.farmsoftlibraries.Utils.CsvUtil;
etc. etc. etc...
I want to stress that I've changed NOTHING in the gradle files. I have been upgrading Android Studio on the Canary path - I'm on 1.4 Preview 3 now. When this issue began I was on 1.4 Preview 2. I have no idea if this is related to this version of Studio.
My gradle scripts:
project settings.gradle:
include ':app'
include ':farmsoftlibs'
project(':farmsoftlibs').projectDir = new File('../FarmSoftLibraries/app')
app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.farmsoft.spellingtutor"
minSdkVersion 15
targetSdkVersion 22
versionCode 28
versionName "1.15"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
applicationIdSuffix '.debug'
versionNameSuffix '.debug'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile project(':farmsoftlibs')
}
farmsoftlibs build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/gson-2.3.1.jar')
compile 'com.google.android.gms:play-services-vision:7.8.0'
}
I do want to admit I pretty much am ignorant about gradle - I follow the instructions for how to set it up in Android Studio, but I really don't know what I'm doing and have gotten lost in the Gradle documentation I tried to read. So this is incredibly frustrating and more so knowing that this is probably due to some stupid mistake I've made out of ignorance.
EDIT:
This seems to have something to do with ProGuard - if I change the library's release settings to say minifyEnabled false, then the error goes away... for now. I'd like to know why.

org.apache.http.legacy not being imported into project [duplicate]

Background
On Android Marshmallow, Google has completely removed the support of Apache HTTP client (link here) because it doesn't have good performance compared to the alternatives.
This might also be the cause for so many apps crashing on Android Marshmallow.
The problem
Google allows you to still use this API, just not as a built in one, by adding this line to the gradle file:
useLibrary 'org.apache.http.legacy'
So, this is what I did:
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
And:
android {
compileSdkVersion 'android-MNC'
buildToolsVersion "23.0.0 rc3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.user.androidmtest"
minSdkVersion 'MNC'
targetSdkVersion 'MNC'
versionCode 1
versionName "1.0"
}
When I tried it, it compiled fine (no errors being shown, and I could run the proof-of-concept app, as it doesn't have any special code), but when I tried using some of the classes that I know that are part of the old API (like "HttpClient" class), I see that it doesn't allow me to do so.
I know it's not recommended to use this solution, but we must have the app ready to work there at least temporarily, till we work 100% on all of the things that should change for Android Marshmallow, and we don't want surprises in the form of crashes.
Here's a screenshot:
The question
Why does it occur? Did I use it correctly?
EDIT: reported about this issue here:
https://code.google.com/p/android/issues/detail?id=181474
Android Studio was complaining that org.apache.http classes like
org.apache.http.NameValuePair
org.apache.http.client.utils.URLEncodedUtils
were missing.
So I added org.apache.http.legacy.jar which is in
Android/Sdk/platforms/android-23/optional folder to to app/libs
I also added this line to my app.gradle file
compile files('libs/org.apache.http.legacy.jar')
But if you're using more libraries, you can use this way
compile fileTree(dir: 'libs', include: ['*.jar'])
This resolved all my errors that were caused because google removed support of Apache HTTP client.
useLibrary 'org.apache.http.legacy' did not work for me until I upgraded the Gradle tools version in my main build.gradle file of my Android Studio project, as follows:
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
Perfect solution here by running a simple file path check.
by running
android {
compileSdkVersion 'android-MNC'
buildToolsVersion "23.0.0 rc3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.user.androidmtest"
minSdkVersion 'MNC'
targetSdkVersion 'MNC'
versionCode 1
versionName "1.0"
}
getBootClasspath().each{File file ->
println file.absolutePath
}
}
}
You will get something like below
/Users/"yourname"/Development/android-sdk-macosx/platforms/android-MNC/android.jar
/Users/"yourname"/Development/android-sdk-macosx/platforms/android-MNC/optional/org.apache.http.legacy.jar
So there you go, the jar is there.For some reason it didn't get added to the project. but you can always add it manually I guess.
The answer above just helps the debug builds to run, and release builds that are utilizing gradle.
Insert this inside the application tag on the manifest file, on all project instances that uses the legacy apache classes:
<uses-library android:name="org.apache.http.legacy" android:required="false" />
This helps for those who are still using Eclipse and ant scripts during compile.
After many frustrating hours, the following worked:
1. Locate the apache jar.
It should reside somewhere like:
C:\Users\<yourname>\AppData\Local\Android\sdk\platforms\android-23\optional
2. Copy org.apache.http.legacy.jar to your libs folder.
Either right click on libs -> paste , or use your file explorer to navigate to the libs folder of your project and paste.
If you don't have a libs folder, as I did, make a new project and import all relevant files into their respective places.
3. Click ok
see this
4. Most important step: Right click on the apache folder and select Add As Library.
see this
Hope this helps someone get on with their life.
I know this is silly reason but at list try it...
I experienced this problem recently, and it is caused by the path length restriction I think it´s 256 characters maximum.
Relocate your Project and the build will succeed.Hope this work for you.
Legacy Apache library located in
[ANDROID_SDK]\platforms\android-23\optional\org.apache.http.legacy.jar
So you can copy it inside you project libs or just use
compile files("${android.getSdkDirectory().getAbsolutePath()}" + File.separator + "platforms" + File.separator + "android-23" + File.separator + "optional" + File.separator + "org.apache.http.legacy.jar")
in your /app/build.gradle
First you have to check that in your libs folder
Then add into your gradle file like this
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "info.tranetech.laundry"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1
compile 'com.android.support:design:23.0.1
testCompile 'junit:junit:4.12'
compile files('libs/android-async-http-1.4.4.jar')
compile 'com.google.android.gms:play-services:8.4.0'
}
Enable this in sdk/platforms/android-23/optional/optional.json
[
{
"name": "org.apache.http.legacy",
"jar": "org.apache.http.legacy.jar",
"manifest": false
}
]
Remove
useLibrary 'org.apache.http.legacy'
from the build.gradle and I also added this line to my app.gradle file
compile files('libs/org.apache.http.legacy.jar')
But if you're using more libraries, you can use this way
compile fileTree(dir: 'libs', include: ['*.jar'])
CoPLaS answer fixed my problems.
How to use the legacy Apache HTTP client on Android Marshmallow?
To continue using Apache HTTP classes for API 23+:
First of all, be sure to add the gradle dependencie into the build.gradle f
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
Then add the reference inside build.gradle of your project:
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
...
}
A simple way to solve this issue is C:\Users\username\AppData\Local\Android\sdk\platforms. Here delete your android-23 and from SDK manager update your API 23 again. It will solve your issue.

Failed to find: com.android.support:support-v4:22.2.0

I am trying to do an application but there seems to be some error with the gradle files now. It was working fine until I upgraded the support libraries.
I was working with api 21 which worked fine, but then i upgraded to api22 and changed the gradle files accordingly.. Now this error shows up.
Error:Failed to find: com.android.support:support-v4:22.2.0
This is my current gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.sampleapp"
minSdkVersion 12
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.jakewharton:butterknife:6.1.0'
}
Any help would be appreciated.
If this might help someone, after MANY trials and errors, I found that I was targeting the wrong SDK version (an older one) in the build.gradle file corresponding to "library". To change this you can do it by hand or go to the Module Settings Menu (right click on your project folder -> Open Module Settings. Then in "library" - Properties you can change the Compile Sdk and the Build Tools Versions
Using Android SDK Manager. Go to Extras and then Android Support Repository and update it to the latest version.
(This is essentially the comment #natario made, but it should be an answer.)

Android Studio can't find imported library

I've imported a library in Android studio (0.5.3)
My settings.graddle looks like this:
include ':app', ':libs:Android-PullToRefresh-master'
And my build.graddle looks like this:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:support-v4:19.+'
compile 'com.google.android.gms:play-services:4.2.42'
compile fileTree(dir: 'libs', include: ['*.jar'])
project(':libs:Android-PullToRefresh-master');
}
The folder I've downloaded is placed in the libs folder directly under the app folder. Also the graddle syncs and building doesn't provide any error. Yet whenever I try to import import com.handmark.xxxxxx; I get the error cannot resolve symbol 'handmark'. I've chcecked to project structure and the app has the dependency in the list.
What is going wrong and how can I fix this?
I ran into the same issue here and asked the question on the "Android Developer Tools" Google+'s community. Alex Ruiz picked up the conversation and told me:
I'm able to reproduce this issue. Unfortunately, no updates yet. We
are currently fixing the "Project Structure" (the core
infrastructure,) and we will get to this, hopefully soon.
So they are aware of it but we still have to wait until they fix it.
In the root of your project, run :
./gradlew clean && ./gradlew build
Then recompile your project in studio and you should see your new lib.
I had the exact same problem as this, however the library file was an aar file, and it happened a long time after adding the library and developing with it for a while.
Building on the information Thomas provided; I found to fix this you should replace the file dependency with a maven dependency if possible. A good resource for finding and creating your Gradle dependency is Gradle, please.
That site returns the below dependency when searching for PullToRefresh
dependencies {
compile 'com.loopeer.android.thirdparty.pulltorefresh:Android-PullToRefresh:2.1.1'
}

Categories

Resources