Watson Conversation autogenerate Android app - 'Unknown pattern character 'X'' - android

I'm using the auto generated example from IBM Watson Mobile App, but when i tried to run it, it shows an error in the following part of code. I found similar errors around SO, but i think this is another one different.
public ServiceCall<MessageResponse> message(String workspaceId, MessageRequest request) {
Validator.isTrue((workspaceId != null) && !workspaceId.isEmpty(), "'workspaceId' cannot be null or empty");
RequestBuilder builder = RequestBuilder.post(String.format(PATH_MESSAGE, workspaceId));
builder.query(VERSION_PARAM, versionDate);
if (request != null) {
//the error shows here
builder.bodyJson(GsonSingleton.getGson().toJsonTree(request).getAsJsonObject());
} else {
builder.bodyJson(new JsonObject());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MessageResponse.class));
}
The following is my build.gradle file:
apply plugin:'base'
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.ibm.watson_conversation"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
manifestPlaceholders = ['appIdRedirectScheme': android.defaultConfig.applicationId]
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
warning 'InvalidPackage'
abortOnError false
}
}
dependencies {
compile ('com.ibm.mobilefirstplatform.clientsdk.android:core:[2.0.0,3.0.0)')
compile 'com.ibm.watson.developer_cloud:conversation:3.8.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
}

The issue was fixed in 3.9.0.
You just need to update the dependency version to be 3.9.1:
compile 'com.ibm.watson.developer_cloud:conversation:3.9.1'

Related

Room Persistence inside of Lib

I am looking for a good way to import Room Persistence inside of my Lib to export .aar . I have the following issue that .aar cannot handle dependencies.
When I export my arr and import into another project as lib, it seems as it has no scope to room.
my lib Gradle file :
apply plugin: 'com.android.library'
apply plugin: 'maven'
archivesBaseName = '*****'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 5
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Write out the current schema of Room
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
deployerJars
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'android.arch.persistence.room:runtime:1.1.0-beta3'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.0-beta3'
}
Thanks.

Migrating to gradle 3.+ with libraries that compile different flavors

I have a very complex project with many libraries that are dependent on each other. I have gone through all of the documentation and videos but nothing is pointing me in the right direction to compile libraries based on flavors. I am confused with the project aspect. If anyone can point me in the right direction to update compile to implementation, that would be great. How do I directly replace configuration: to match the flavors?
Here in an example of two gradles.
vnfmdata
android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
publishNonDefault true
flavorDimensions flavor.default
productFlavors {
regular {}
no_meridian {}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
regularCompile project(':vncore')
regularCompile project(path: ':vnlocationservice', configuration: 'meridianDebug')
no_meridianCompile project(':vncore')
no_meridianCompile project(path: ':vnlocationservice', configuration: 'no_meridianDebug')
}
vnlocationservices
android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
publishNonDefault true
productFlavors {
no_meridian {}
meridian {}
}
buildTypes {
release {
//minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile deps.support.app_compat
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
no_meridianCompile project(':vncore')
meridianCompile project(':vncore')
meridianCompile project(':third:Sas-Android')
//Localytics
meridianCompile deps.support.compat_v26
meridianCompile deps.play.ads
meridianCompile deps.play.location
meridianCompile deps.localytics
///////////////////
meridianCompile 'com.arubanetworks.meridian:meridian:+#aar'
}
edit:
I found that adding a dependencies node into a flavor affected the other flavor. Instead it is better to use <flavor's name>Implementation.
As you stated, you probably went into the Migration Guide resolve matching errors.
vnfmdata
Here the changes are located on the flavors and how the dependencies changed:
android {
...
productFlavors {
regular {
// Forces regular's flavor to point on LocationService meridian's flavor
// because their flavors' name are different
matchingFallbacks = ["meridian"]
}
no_meridian {
// Will automatically point on LocationService no_meridian's flavor
// because they both have the same name
}
}
...
}
dependencies {
// We used the flavors' matching feature
// so gradle knows that if you select regular, you wants the meridian flavor on these 2 projects
implementation project (":vncore")
implementation project (":vnlocationservice")
}
vnlocationservices
Here we see how to declare a dependency which is only use by one flavor.
android {
...
productFlavors {
meridian {}
no_meridian {}
}
...
}
dependencies {
implementation project (":vncore")
meridianImplementation project(':third:Sas-Android')
//Localytics
meridianImplementation deps.support.compat_v26
meridianImplementation deps.play.ads
meridianImplementation deps.play.location
meridianImplementation deps.localytics
///////////////////
meridianImplementation 'com.arubanetworks.meridian:meridian:+#aar'
}
}

"cannot find symbol method metafactory" using Lambda

I'm using java 8 and lambda expressions. When I use lambda expressions with OnClickListeners everything is fine, but when I use that in this animate method:
public void configureFragmentToolbar(String title, boolean displayHomeAsUpEnabled) {
//..
this.toolbar.animate().translationY(-50).setDuration(300).withEndAction(() -> { //ERROR
toolbar.animate().translationY(0).setDuration(300);
});
}
I´m getting this error:
"error: cannot find symbol method
metafactory(Lookup,String,MethodType,MethodType,MethodHandle,MethodType)"
gradle:
apply plugin: 'com.android.library'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'org.sonarqube'
def junitVersion = '4.12'
def mockitoVersion = '1.10.19'
def daggerVersion = '2.5'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':commons')
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:27.0.2'
testCompile "junit:junit:$junitVersion"
testCompile "org.mockito:mockito-core:$mockitoVersion"
apt "com.google.dagger:dagger-compiler:$daggerVersion"
}
Can you tell me why I'm getting that error? Thank you
In $ANDROID_SDK/build-tools/27.0.3/, missing the file : core-lambda-stubs.jar. You just need reinstall the build tool.
Try to downgrade android build tools to:
classpath 'com.android.tools.build:gradle:3.1.4'

Plugin not found when importing project as library in Android Studio

I am trying to integrate an application to another one. To do that I compiled the first one as a library and after that I added it to the dependencies of the application project after I added it as a module following some guides in stackoverflow.
The problem is that after doing that, I got an error about a missing plugin. Although I have researched a bit over google I have had no luck on that one.
The error is Error:(4, 0) Plugin with id 'com.google.protobuf' not found.
Open File
Both applications work very well, each on their own... What am I doing wrong ?
Here is my build graddle of the main app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.arlind.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
Here is the build graddle of the added library
import java.text.SimpleDateFormat
apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
}
}
android {
signingConfigs {
global {
keyAlias "Lind"
keyPassword "gators"
storeFile file("lindkey.keystore")
storePassword "gators"
}
}
compileSdkVersion 22
buildToolsVersion "23.0.0"
android {
lintOptions {
abortOnError false
}
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.global
}
}
productFlavors {
catapult {
versionCode getLongDate().toInteger()
versionName '12.1-' + getShortDate()
}
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '18.0'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
compile project(path: ':wallpaperPicker')
}
sourceSets {
main {
manifest.srcFile '../AndroidManifest.xml'
java.srcDirs = ['../src', '../util', '../extra/src']
res.srcDirs = ['../res', '../extra/res']
proto {
srcDir '../protos'
}
}
}
}
def getDate(String dateFormat) {
def df = new SimpleDateFormat(dateFormat)
Calendar c = Calendar.getInstance();
TimeZone tz = c.getTimeZone();
df.setTimeZone(tz)
return df.format(new Date())
}
def getLongDate() {
return getDate("yyMMddHH")
}
def getShortDate() {
return getDate("yyMMdd")
}

ChannelAPI can not be resolved

I am trying to exchange files between watch and handheld by using the channel API.
But when I tried to open the channel by calling the following code, the ChannelAPI can not be resolved . Its not part of the "wearable" class I am using.
I guess there probably was caused by the wrong Android version. Does anyone know which version should I specify in my config files or how to fix it?
Thanks a lot.
My wear bundle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "mywearapp"
minSdkVersion 20
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4096m"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.0'
compile 'com.google.android.gms:play-services-wearable:7.8.0'
compile project(':shared')
}
Wearable.ChannelApi.openChannel(
mGoogleApiClient, node.getId(), "/mypath").setResultCallback(
new ResultCallback<ChannelApi.OpenChannelResult>() {
#Override
public void onResult(ChannelApi.OpenChannelResult openChannelResult) {
if (openChannelResult.getStatus().isSuccess()) {
mChannel = openChannelResult.getChannel();
mChannel.getOutputStream(mGoogleApiClient).setResultCallback(
new ResultCallback<Channel.GetOutputStreamResult>() {
#Override
public void onResult(Channel.GetOutputStreamResult getOutputStreamResult) {
if (getOutputStreamResult.getStatus().isSuccess()) {
mOutputStream = getOutputStreamResult.getOutputStream();
} else {
// handle failure, and close channel
}
}
});
}
}
});

Categories

Resources