ChannelAPI can not be resolved - android

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
}
}
});
}
}
});

Related

missing binaries for apk to install on device

I have looked at this article
[INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
But i was unable to get any resolution.
right now this is my code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.testapp.testapp"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
splits {
abi {
enable true
reset()
include 'arm64-v8a'
universalApk true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation('me.dm7.barcodescanner:zxing:1.9') { exclude module: 'support-v4' }
implementation 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
implementation 'org.bitcoinj:bitcoinj-core:0.14.7'
api 'org.slf4j:slf4j-api:1.7.25'
implementation 'org.slf4j:slf4j-simple:1.7.12'
}
And also my mainactivity
public class MainPage extends AppCompatActivity {
public static NetworkParameters BTCparams = TestNet3Params.get();
public static WalletAppKit BTCkit = new WalletAppKit(BTCparams,new File("."),"BTC-Test");
static String[] account;
static String[] server;
private Handler handler = new Handler();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tVBTCPer = (TextView)findViewById(R.id.tVBTCPer);
TextView tVNull = (TextView)findViewById(R.id.tVNull);
tVNull.setText(System.getProperty("os.arch"));
DownloadProgressTracker BTCListener = new DownloadProgressTracker() {
#Override
public void progress(double pct, int blocksSoFar, Date date) {
tVBTCPer.setText((int) pct+"%");
}
#Override
public void doneDownload() {
tVBTCPer.setText("100%");
}
};
BTCkit.setDownloadListener(BTCListener).setBlockingStartup(false).startAsync().awaitRunning();
}
I used this library to make java applications for pc/linux and it works fine. But when im trying to compile this for android to be usable it gets hung up trying to install the apk onto my device.
my os.arch is aarch64. I also have a previous post in stackoverflow to help give it some context.
Bitcoinj library on android hung on installing APK
I am not entirely sure what library i would need to help this apk install onto my device.

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.

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

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'

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")
}

onMessageReceived() never called, although connected to handheld

I want to send Messages from a handheld device to a smartwatch (Moto360) only when a message comes up.
I made sure that both modules have the same package name, debug.key and version number.
The listener gets added in onConnected() and the function is always called.
Here is my Handheld gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "de.bachelorthesis.important"
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file("../debug.keystore")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile files('libs/commons-io-2.4.jar')
compile files('libs/mapquest-android-sdk-1.0.5.jar')
compile files('libs/osmdroid-android-4.2.jar')
compile files('libs/slf4j-android-1.7.7.jar')
wearApp project(':wear')
}
In my handheld Activity the message should be sent like this:
private void sendToSmartwatch(msg) {
final String msg_arg = msg;
new Thread(new Runnable() {
public void run() {
mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
.addApi(Wearable.API)
.build();
ConnectionResult connectionResult =
mGoogleApiClient.blockingConnect(5, TimeUnit.SECONDS);
NodeApi.GetLocalNodeResult nodes =
Wearable.NodeApi.getLocalNode(mGoogleApiClient).await(3, TimeUnit.SECONDS);
com.google.android.gms.wearable.Node node = nodes.getNode();
MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(
mGoogleApiClient, node.getId(), CONSTANT, msg_arg.getBytes()).await();
Log.d("node:result: ", "" + result.getStatus());
if (result.getStatus().isSuccess()) {
// Log success
}
else {
// Log an error
}
mGoogleApiClient.disconnect();
}
}).start();
}
The Wearable gradle.build file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "de.bachelorthesis.important"
minSdkVersion 20
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file("../debug.keystore")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.support:wearable:1.1.0'
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:22.0.0'
}
And eventually, the message should come up here on my watch:
public class MainActivity extends Activity implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
...
onCreate(){
mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext())
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleApiClient.connect();
}
mListener = new MessageApi.MessageListener() {
#Override
public void onMessageReceived(MessageEvent messageEvent) {
if (messageEvent.getPath().equals(CONSTANT)) {
//do stuff with the message
}
}
};
}
#Override
public void onConnected(Bundle bundle) {
Wearable.MessageApi.addListener(mGoogleApiClient, mListener);
}
I have tried several different Listeners like the ListenerService (also with the BIND_LISTENER in the manifest.xml)
Also I have tried the PhoneService Class from this answer.
Any suggestions what I am doing wrong?
EDIT: I forgot to mention that the message gets sent from the handheld successfully, but it is not received.
EDIT 2: Could it be an issue, that my handheld module has the name "app" instead of "mobile"?! Also it is a project that i migrated from eclipse, to add the wearable feature.
So, i figured it out myself:
This project was helping.
I think the Constants made the difference. It was no path, but a randomly set constant by me. Still not sure, tho.

Categories

Resources