I'm using Android Studio 1.1.0. When I try to sync my Gradle file, I get the following error:
Gradle DSL method not found:storeFile()
Here is my gradle configuration:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "skripsi.ubm.studenttracking"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
signingConfigs {
release {
storeFile (project.property("Students_tracking_keystore.jks") + ".keystore")
storePassword "####"
keyAlias "####"
keyPassword "#####"
}
}
}
Can anyone help?
A couple of things to note:
The storeFile DSL method has the following signature:
public DefaultSigningConfig setStoreFile(File storeFile)
i.e. it expects a File to be passed in. You probably need to place a File constructor in your code to ensure you are actually creating a File object. Because you're currently not passing in a file, Gradle is complaining that it can't find a method with the appropriate signature.
Secondly, you are currently appending two suffices to the filename: .jks and .keystore. You should only include one of these based on the suffix of the file you are referencing (it's probably .jks, but you should check to be sure).
In short, one of the following replacement lines will probably work for you:
storeFile file(project.property("Students_tracking_keystore") + ".keystore")
or
storeFile file(project.property("Students_tracking_keystore") + ".jks")
or
storeFile file(project.property("Students_tracking_keystore.keystore"))
or
storeFile file(project.property("Students_tracking_keystore.jks"))
Related
I am working on a app for school in android studio using java
I want to generate multiple apk for school with their school name and logo, (about 50+ schools)
Is there any way to save time generating one by one
in future need to update all
Read official guideline about productFlavors.
Creating product flavors is similar to creating build types: add them
to the productFlavors block in your build configuration and include
the settings you want. The product flavors support the same properties
as defaultConfig—this is because defaultConfig actually belongs to the
ProductFlavor class.
productFlavors {
elvispresley {
applicationId 'your_package_id'
versionCode 1
versionName '1.0'
}
whitneyhouston {
applicationId 'your_package_id_2'
versionCode 2
versionName '2.0.1'
}
projectOne {
applicationIdSuffix ".one"
}
projectTwo {
applicationIdSuffix ".two"
}
}
In my react native project I earlier added aws amplify for push notification. After that I wanted to do analytics, so I added firebase to it. After that, my android app build but stops as soon as it launches.
I get error as
java.lang.RuntimeException: Unable to instantiate service
com.amazonaws.amplify.pushnotification.RNPushNotificationMessagingService:
java.lang.ClassNotFoundException: Didn't find class
"com.amazonaws.amplify.pushnotification.RNPushNotificationMessagingService
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/firebase/messaging/FirebaseMessagingService;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 10 more
Caused by: java.lang.ClassNotFoundException: com.google.firebase.messaging.FirebaseMessagingService
My app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
packagingOptions {
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
defaultConfig {
applicationId "com.project”
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2
versionName "1.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
manifestPlaceholders = [
appAuthRedirectScheme: 'com.project’
]
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-firebase')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-reanimated')
implementation project(':#react-native-community_netinfo')
compile project(':react-native-charts-wrapper')
compile project(':rn-fetch-blob')
compile project(':react-native-wheel-picker')
compile project(':react-native-vector-icons')
compile project(':react-native-pdf')
compile project(':react-native-app-auth')
compile project(':#aws-amplify_pushnotification')
implementation (project(':react-native-device-info')){
exclude group: "com.google.android.gms"
exclude group: "com.android.support"
}
implementation project(':react-native-wheel-picker')
implementation project(':react-native-vector-icons')
implementation project(':amazon-cognito-identity-js')
implementation project(':#aws-amplify_pushnotification')
implementation project(':react-native-app-auth')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
// Firebase dependencies
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
//com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
You have to either use compile or implementation, not both. Remove these lines.
compile project(':react-native-wheel-picker')
compile project(':#aws-amplify_pushnotification')
compile project(':react-native-vector-icons')
compile project(':react-native-app-auth')
When you set up AWS Amplify push notifications, you have to first set up a Firebase project that AWS Amplify will hook into.
You can Enable Google Analytics in the Firebase project setup process.
Then include the line implementation 'com.google.firebase:firebase-analytics:17.2.1' in android/app/build.gradle.
I've created a walkthrough for the Firebase setup process for AWS Amplify, containing images for the various steps.
I am a newbie with Android Studio. I am trying to use this project library : https://github.com/2dxgujun/AndroidTagGroup in my project.
So what I did is to import it as a module in my project ; with the name "androidtaggroup"
Now, I have got the following error at compilation:
"Could not get unknown property 'VERSION_NAME' for project ':androidtaggroup' of type org.gradle.api.Project."
Here is where the problem occurs in the Gradle file:
defaultConfig {
applicationId 'me.gujun.android.taggroup.demo'
minSdkVersion 8
targetSdkVersion 21
versionName project.VERSION_NAME // ERROR HERE !!!!
versionCode Integer.parseInt(project.VERSION_CODE)
}
Anybody can tell me how to fix this problem ?
Thanks !!!
The fix is to define your version name there or use a custom made variable. project.VERSION_NAME does not exists by default, therefore you can't use it. That is basically what the error message is telling you.
defaultConfig {
applicationId 'me.gujun.android.taggroup.demo'
minSdkVersion 8
targetSdkVersion 21
versionName "1.2.3"
versionCode Integer.parseInt(project.VERSION_CODE)
}
or alternative:
// somewhere above
def VERSION_NAME = "1.2.3"
// and the usage:
defaultConfig {
applicationId 'me.gujun.android.taggroup.demo'
minSdkVersion 8
targetSdkVersion 21
versionName VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
And after you have changed that you will probably run into the same issue for using project.VERSION_CODE:
versionCode Integer.parseInt(project.VERSION_CODE)
Fix is the same: provide a valid self defined variable or constant
buildscript {
ext.kotlin_version = '1.3.31'
ext.room_version = '2.1.0-alpha01' // Add this line in your build gradle
repositories {
google()
jcenter()
}
I had a similar problem. 'VERSION_NAME' was not defined in the ext{} from build.gradle(Project: 'PROJECT_NAME')
I'm trying to include a c file, ImageProc into my java file to use it's functions.
I got the code from a MjpegInputStream file (where everything is supposed to work, but of course its never that easy)
Here is the code that crashes (somehow the catch isn't catching it)
static {
try {
System.loadLibrary("ImageProc");
}
catch (Exception e){
e.getMessage();
}
}
The makefile is:
include $(CLEAR_VARS)
LOCAL_MODULE := ImageProc
LOCAL_SRC_FILES := ImageProc.c
LOCAL_LDLIBS := -llog -ljnigraphics
LOCAL_SHARED_LIBRARIES := prebuilt-libjpeg
LOCAL_C_INCLUDES := external/include jni/external/include
So to my understanding I should just be able to use ImageProc.
I know it went through and compiled the c file because at first it couldn't find the h file references (fixed now).
One other thing i'm not sure about is that I call the function pixeltobmp which in the c file is defined as Java_com_camera_simplemjpeg_MjpegInputStream_pixeltobmp which strikes me as odd. I tried changing the name of the method to include the package i'm using rather than the one I copied it from, but that didn't fix anything.
Any help is appreciated.
Additional info: I'm using gradle build 2.10
1. Compile your library
2. Check if you have the .so compiled library(this is important!)
3. In your gradle file add this:
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
sourceSets.main {
jni.srcDirs = []
File configFile = file('pathToYourLibsFolder')
jniLibs.srcDir configFile.absolutePath
}
Then it should work.
In build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
...
}
buildTypes {
...
}
ndk {
moduleName "ImageProc"
// stl "stlport_static"
// ldLibs "log"
}
}
}
As an alternative option, the code that you're using can be easily modified to remove the dependency on OpenCV (or it can now 2 years after you asked the question).
MjpegInputStream.java has two relevant methods, readMjpegFrame() and readMjpegFrame(Bitmap bmp).
Only the later relies on OpenCV and therefore the native library dependency. If you modify the code to remove this method, and then remove:
static {
System.loadLibrary("ImageProc");
}
public native int pixeltobmp(byte[] jp, int l, Bitmap bmp);
public native void freeCameraMemory();
You will no longer have this problem and can still use readMjpegFrame() to get the content you want.
Whether this is less performant, I'm not certain, but it's working fine in my use case.
My Gradle dependencies includes:
compile'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.google.android.gms:play-services-ads:8.1.0
I am getting BUILD FAILED with error:
Error:Execution failed for task ':app:processDebugResources.
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
How can I solve this problem?
Use gradle androidDependencies to learn where the duplicate Google Play Services is coming from. Then use exclude to filter the duplicates out in your Gradle dependencies, e.g.
compile('something.that.includes.google.play.services:1.2.3') {
exclude group: 'com.google.android.gms'
}
I had the same problem and I solved by adding this line android.enforceUniquePackageName = false in build.gradle(app) like this:
buildTypes {
release {
...
... ...
}
}
android.enforceUniquePackageName = false
The easiest way is to replace these dependencies by the whole package :
compile 'com.google.android.gms:play-services:8.1.0'
Then you could probably compile it.
OR add android.enforceUniquePackageName = false in your build.gradle.
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 9
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
android.packageBuildConfig = false
android.enforceUniquePackageName = false
}