could not find method signingConfig() - build.gradle

i was trying to make release and debug variants of my app so i made some changes to build.gradle of my project but when i tried to sync gradle file there is an error occured.
here is my gradle file code
release{
storeFile file("C:\\Users\\jitendra\\AndroidStudioProjects\\NewsApp\\config\\NewsAppKey.jks");
storePassword("Password123");
keyAlias("NewsAppKey");
keyPassword("Password123");
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
signingConfig signingConfig.release
}
debug{
debuggable true
applicationIdSuffix ".debug"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg','proguard_debug.cfg'
}
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
here is error
Error:(15, 0) Could not find method signingConfig() for arguments [build_c5ycoyx8ri4a8n6vogeddf49z$_run_closure1$_closure4#6ca2a2ce] on object of type com.android.build.gradle.AppExtension.
Open File

Should be signingConfig signingConfigs.release not signingConfig signingConfig.release (note the extra "s").
Also, I would suggest avoiding giving the signing config the same name as your build type, as it can confuse Gradle. I always give it a different name, even something like "scRelease" should be okay.

Related

Is it possible to get details with the Android Studio lint tool?

I use lint to check an Android app project:
gradlew lint
It shows the following:
> Task :app:compileOfficialDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
The process generates two files: lint-results.html and lint-results.xml. I checked both files, but could not find any information related to deprecated API. Is it possible to generate more details about deprecated API in these two files?
Here's an example "build.gradle" I marked up:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
multiDexEnabled true
applicationId "com.boxpik.android"
minSdkVersion 17
targetSdkVersion 19
...
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
...
In this example, I added options.compilerArgs << "-Xlint:all" to build.gradle.
This gave me a bunch of Lint warning in my Android Studio "Build" window:
^
C:\xyz\PoolToScoreDetailFragment.java:55: warning: [deprecation] ProgressDialog in android.app has been deprecated
private ProgressDialog pDialog;
^
C:\xyz\PoolToScoreDetailFragment.java:346: warning: [deprecation] ProgressDialog in android.app has been deprecated
pDialog = new ProgressDialog(application);

getting DuplicateFileException while building Apk

I am getting a DuplicateFileException while building Apk. I used the Applogic source code from GitHub to develop a chat app and while building the gradle I got this exception not able to build the apk. I am using Android Studio 3.0 Gradle version 3.3 and Android Plugin version 2.3.3 Build tool version 26.0.2 sdk version API26
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.mobicomkit.sample"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':mobicomkitui') //Note: use this for customization
compile 'com.applozic.communication.uiwidget:mobicomkitui:5.2'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:26.0'
compile 'com.android.support:recyclerview-v7:26.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7#aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'enter image description here
You cant use the both at a time gradle dependency and imported applozic source code and any one you need to use
Use this in your case you imported source code
compile project(':mobicomkitui') //Note: use this for customization
Remove this code from your app build.gradle file
compile 'com.applozic.communication.uiwidget:mobicomkitui:5.2'

How do I configure jooq with Gradle and Mysql for a single database

I'm trying to use jooq to load configurations automatically from gradle but had a hard time following the guide.
I finally have it loading data, but so far I can only get all databases to work (by having the database() chunk be blank).
My code below has my attempt to load only one database.
buildscript {
repositories {
mavenCentral()
maven {
name 'JFrog OSS snapshot repo'
url 'https://oss.jfrog.org/oss-snapshot-local/'
}
jcenter()
}
dependencies {
classpath 'org.jooq:jooq-codegen:3.9.1'
classpath group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
}
}
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'antlr'
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
//compile group: 'com.github.javaparser', name: 'javaparser-core', version: '3.0.0-alpha.2'
compile group: 'com.github.javaparser', name: 'java-symbol-solver-core', version: '0.5.2'
compile 'org.jooq:jooq:3.9.1'
runtime group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
testCompile "junit:junit:latest.release"
}
idea {
module {
excludeDirs += file('src/main/resources')
}
}
// Use your favourite XML builder to construct the code generation configuration file
// ----------------------------------------------------------------------------------
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
.configuration('xmlns': 'http://www.jooq.org/xsd/jooq-codegen-3.9.0.xsd') {
jdbc() {
driver('com.mysql.cj.jdbc.Driver')
url('jdbc:mysql://127.0.0.1/graphUpgrade?serverTimezone=UTC')
user('parseUser')
password('password')
}
generator() {
database() {
name('org.jooq.util.mysql.MySQLDatabase')
inputSchema('graphUpgrade')
includes('.*')
}
// Watch out for this caveat when using MarkupBuilder with "reserved names"
// - https://github.com/jOOQ/jOOQ/issues/4797
// - http://stackoverflow.com/a/11389034/521799
// - https://groups.google.com/forum/#!topic/jooq-user/wi4S9rRxk4A
generate([:]) {
pojos true
daos true
}
target() {
packageName('us.klingman.codeParser.db')
directory('src/main/java')
}
}
}
print writer.toString()
// Run the code generator
// ----------------------
org.jooq.util.GenerationTool.generate(
javax.xml.bind.JAXB.unmarshal(new StringReader(writer.toString()), org.jooq.util.jaxb.Configuration.class)
)
Running this code produces the following error:
Error while fetching tables
java.lang.NullPointerException
at org.jooq.util.AbstractElementContainerDefinition.<init>(AbstractElementContainerDefinition.java:79)
at org.jooq.util.AbstractElementContainerDefinition.<init>(AbstractElementContainerDefinition.java:75)
at org.jooq.util.AbstractTableDefinition.<init>(AbstractTableDefinition.java:68)
at org.jooq.util.mysql.MySQLTableDefinition.<init>(MySQLTableDefinition.java:70)
at org.jooq.util.mysql.MySQLDatabase.getTables0(MySQLDatabase.java:256)
at org.jooq.util.AbstractDatabase.getTables(AbstractDatabase.java:1137)
at org.jooq.util.AbstractDatabase.getTable(AbstractDatabase.java:1163)
at org.jooq.util.AbstractDatabase.getTable(AbstractDatabase.java:1158)
at org.jooq.util.mysql.MySQLDatabase.getEnums0(MySQLDatabase.java:295)
at org.jooq.util.AbstractDatabase.getEnums(AbstractDatabase.java:1182)
at org.jooq.util.JavaGenerator.generateSchemaIfEmpty(JavaGenerator.java:334)
at org.jooq.util.JavaGenerator.generateCatalogIfEmpty(JavaGenerator.java:323)
at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:297)
at org.jooq.util.GenerationTool.run(GenerationTool.java:610)
at org.jooq.util.GenerationTool.generate(GenerationTool.java:199)
at org.jooq.util.GenerationTool$generate.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at build_87hklhc6v691dvh83y5ogqnvl.run(/Users/lorenklingman/Sites/code-search-parser/build.gradle:79)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:74)
Finally, for completeness, here are the files generated for all databases.
I believe you've run into this problem here: #5213
Be sure to always use the exact upper/lower case writing of your database name also in the jOOQ configuration. Also, there are some caveats with case sensitivity in MySQL and MariaDB, depending on the operating system. These caveats can affect other tools than jOOQ. The relevant info is also in #5213.

TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$1.class

I migrated source code from Eclipse to Android studio, when I build the project in android studio, I got the following failure.
FAILURE: Build failed with an exception.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$1.class
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile (project(':facebook')){
exclude group: 'com.android.support', module: 'multidex'
}
compile project(':libraryBasePera')
compile project(':google-play-services_lib')
compile 'com.android.support:multidex:1.0.1'
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
I tried many ways (exclude module support-v4, deleted support-v4 jar, clean, rebuild project...) but I am still stuck here. Can any one help me to figure out the problem?
Thank you very much.
Try to check lib folder. I had same error because I have added support-v4 jar in my lib folder by mistake.

I'm getting java.lang.UnsatisfiedLinkError when I run my jUnit test on command line by gradle, but it runs fine when run on AndroidStudio

So I finally managed to get my android studio to run JUnit test that's integrated with robolectric so I can do http calls and other things without running it on device or emulator. Followed the structure from here which worked wonders: https://github.com/robolectric/deckard-gradle
Now, I managed to run it fine on AndroidStudio, however I want to setup a cron so it can be run automatically, and when executing the test by command line via gradle I am getting "java.lang.UnsatisfiedLinkError: no pjsua in java.library.path". Note that our code uses a pjsip lib code that we compile separately, and we put the .so file in the jniLibs folder. I have another jUnit test that's really simple, and that one works fine whether through gradle command line or AndroidStudio.
The gradle command I followed from http://tools.android.com/tech-docs/unit-testing-support which are either:
1) ./gradlew test --continue
or
2) ./gradlew test -Dtest.single=Test.java
This is what our gradle file looks like for the app layer:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.foo.test"
minSdkVersion 14
targetSdkVersion 21
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "libpjsua"
}
}
sourceSets {
main {
jni.srcDirs = []
}
}
signingConfigs {
// hidden
}
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/android-logging-log4j-1.0.3.jar')
compile files('libs/libphonenumber-6.2.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/ostermillerutils_1_07_00.jar')
// dependencies to do automation testing
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.1'
testCompile 'org.hamcrest:hamcrest-library:1.1'
testCompile 'org.hamcrest:hamcrest-integration:1.1'
testCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
}
}
Does anyone have any idea? Many thanks in advance, been at this for a couple of days now.