NativeScript Failed resolving method create on class okhttp3.RequestBody - nativescript

I'm using NativeScript 6.0 with Angular 8.0 and trying to use the nativescript-http-formdata plugin and keep running into a dependency issue;
LOG from device Galaxy S8: Error: java.lang.Exception: Failed resolving method create on class okhttp3.RequestBody
Full Error;
LOG from device Galaxy S8: Taken picture
LOG from device Galaxy S8: Gallery: /storage/emulated/0/DCIM/Camera/NSIMG_20190821_10221.jpg
LOG from device Galaxy S8: Saved: /data/user/0/org.nativescript.preview/files/NSIMG_20190821_10221_thumbnail.jpg
LOG from device Galaxy S8: com.tns.Runtime.resolveMethodOverload(Runtime.java:1201)
LOG from device Galaxy S8: com.tns.Runtime.callJSMethodNative(Native Method)
LOG from device Galaxy S8: com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
LOG from device Galaxy S8: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
LOG from device Galaxy S8: com.tns.Runtime.callJSMethod(Runtime.java:1109)
LOG from device Galaxy S8: com.tns.Runtime.callJSMethod(Runtime.java:1089)
LOG from device Galaxy S8: FILE: /data/user/0/org.nativescript.preview/files/NSIMG_20190821_10221_thumbnail.jpg
LOG from device Galaxy S8: Image saved successfully!
LOG from device Galaxy S8: Error: java.lang.Exception: Failed resolving method create on class okhttp3.RequestBody
LOG from device Galaxy S8: com.tns.Runtime.callJSMethod(Runtime.java:1081)
LOG from device Galaxy S8: com.tns.NativeScriptActivity.onActivityResult(NativeScriptActivity.java:54)
LOG from device Galaxy S8: android.app.Activity.dispatchActivityResult(Activity.java:7282)
LOG from device Galaxy S8: android.app.ActivityThread.deliverResults(ActivityThread.java:4516)
LOG from device Galaxy S8: android.app.ActivityThread.handleSendResult(ActivityThread.java:4563)
LOG from device Galaxy S8: android.app.ActivityThread.-wrap22(ActivityThread.java)
LOG from device Galaxy S8: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1698)
LOG from device Galaxy S8: android.os.Handler.dispatchMessage(Handler.java:102)
LOG from device Galaxy S8: android.os.Looper.loop(Looper.java:154)
LOG from device Galaxy S8: android.app...
I'm using the nativescript-http-formdata plugin to send a photo
async sendPicture(filepath, imageAsset) {
var url = "http://localhost:9000/images/upload";
var name = filepath.substr(filepath.lastIndexOf("/") + 1);
// Get bitmap of file
const imageAndroidBitmap = android.graphics.BitmapFactory.decodeFile(filepath);
// Prepare the formdata
let fd = new TNSHttpFormData();
let param: TNSHttpFormDataParam = {
data: imageAndroidBitmap,
contentType: 'image/jpeg',
fileName: 'test.jpg',
parameterName: 'file1'
};
let params = [];
params.push(param);
try {
const response: TNSHttpFormDataResponse = await fd.post(url, params, {
headers: {}
});
console.log(response);
} catch (e) {
console.log(e);
}
}
I don't know how to get the okhttp3 dependency installed in NativeScript.
What I've tried so far
Did a 'tns update' just incase my packages were out of date.
Installed nativescript-https as someone said it satisfies the okhttp3 dependency problem
Installed nativescript-okhttp as it looks like the plugin I'm missing.
Update: Add dependency to app.gradle
Within /App_Resources/Android/app.gradle
// Add your native dependencies here:
// Uncomment to add recyclerview-v7 dependency
dependencies {
// implementation 'com.android.support:recyclerview-v7:+'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.10.0'
}
// If you want to add something to be applied before applying plugins' include.gradle files
// e.g. project.ext.googlePlayServicesVersion = "15.0.1"
// create a file named before-plugins.gradle in the current directory and place it there
android {
defaultConfig {
minSdkVersion 17
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Then I restarted my preview
tns preview
Still getting the exact same error message.
Update: Use 6.0 branch of nativescript-http-formdata
Clone repo
cd ~/code/nativescript
git clone https://github.com/dotnetdreamer/nativescript-http-formdata.git
Get 6.0 branch
cd nativescript-http-formdata
git co 6.0
Install plugin directory
cd ~/code/AssetManagementPrototype
tns plugin install /home/map7/code/nativescript/nativescript-http-formdata/src
Run in emulator
tns run android --device emulator-5554
Error;
ERROR in /home/map7/code/nativescript/nativescript-http-formdata/src/TNSHttpFormData.ts
Module build failed (from ../node_modules/#ngtools/webpack/src/index.js):
Error: /home/map7/code/nativescript/nativescript-http-formdata/src/TNSHttpFormData.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at NativeScriptAngularCompilerPlugin.getCompiledFile (/home/map7/code/AssetManagementPrototype/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:838:23)
at NativeScriptAngularCompilerPlugin.getCompiledFile (/home/map7/code/AssetManagementPrototype/node_modules/nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin.js:28:26)
at plugin.done.then (/home/map7/code/AssetManagementPrototype/node_modules/#ngtools/webpack/src/loader.js:41:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
# ./app/home/home.component.ts 11:0-61 216:33-48
# ./app/home/home.module.ts
# ../$$_lazy_route_resource lazy namespace object
# ../node_modules/#angular/core/fesm5/core.js
# ./app/app.module.ts
# ./main.ts
Update: Try nativescript-http-formdata demo
This also failed, Ref: https://github.com/dotnetdreamer/nativescript-http-formdata/issues/19

You need to add that as dependency. For further reading you can refer here.
in Maven:
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.10.0</version>
</dependency>
in Gradle
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.10.0'
or
dependencies {
compile "com.squareup.okhttp3:okhttp:3.10.0"
}
As per the sample provided in their git repo, they adding in src/platforms/android/include.gradle
dependencies {
compile "com.squareup.okhttp3:okhttp:3.10.0"
}

Related

Xamarin VS: Debugging first project does not show project on emulator

Testing out Xamarin on Visual Studio 2017. I have an Android emulator running when I hit the debug to run the program, but my program does not appear on the emulator. Is there some connection issue? If so, where?
Deleting bin folders; creating new project to test; creating new emulator;
Here is the build output:
emulator: android_hw_fingerprint_init: fingerprint qemud listen service initialized
emulator: Warning: config.ini contains invalid skin.path entry: (null)
emulator: Warning: config.ini contains invalid skin.path entry: (null)
emulator: Adding boot property: 'ro.opengles.version' = '196608'
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'back'
emulator: Adding boot property: 'qemu.adb.secure' = '1'
emulator: Adding boot property: 'dalvik.vm.heapsize' = '256m'
emulator: Adding boot property: 'qemu.hw.mainkeys' = '0'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '420'
emulator: Adding boot property: 'monodroid.avdname' = 'my_device'
emulator: Adding boot property: 'qemu.timezone' = 'Unknown/Unknown'
emulator: _hwFingerprint_connect: connect finger print listen is called
audio: Failed to create voice `adc'
emulator: Warning: config.ini contains invalid skin.path entry: (null)
emulator: Warning: config.ini contains invalid skin.path entry: (null)
emulator: Warning: config.ini contains invalid skin.path entry: (null)
UpdateLayeredWindowIndirect failed for ptDst=(780, 216), size=(300x96), dirty=(300x96 0, 0) (A device attached to the system is not functioning.)
UpdateLayeredWindowIndirect failed for ptDst=(780, 216), size=(300x96), dirty=(300x96 0, 0) (A device attached to the system is not functioning.)

System.Net.Http.HttpRequestException exception will running th xamarin UI Test on Physical Device

I have created a simple Xamarin.Forms(Portable) project and included UI Test project in it. But when i am trying to run the test in physical device it giving me below mentioned exception.
Test Name: AppLaunches
Test Outcome: Failed
Result Message:
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request.
----> System.Net.WebException : The underlying connection was closed: The connection was closed unexpectedly.
Result StandardOutput: Full log file: C:\Users\Admin\AppData\Local\Temp\uitest\log-2016-10-22_11-04-53-698.txt
Skipping IDE integration as important properties are configured. To force IDE integration, add .PreferIdeSettings() to ConfigureApp.
Android test running Xamarin.UITest version: 2.0.0.1534
Initializing Android app on device ZX1D63GCCL with installed app: co.veloxcore.UITestSample2
Signing apk with Xamarin keystore.
Skipping installation: Already installed.
Here is the link to my project: XamarinUITest
Log File : Error Log
Are you using using ModernHttpClient?
Also you can use Polly if you want to handle network exceptions.
For example:
conferences = await Policy
.Handle<WebException>()
.WaitAndRetry
(
retryCount:5,
sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
)
.ExecuteAsync(async () => await getConferencesTask);
Also AsyncErrorHandler is great tool to handle async exceptions

Failed to enable Hyperloop

Using a Pro account, I created a new app (using Studio), when tried to enable Hyperloop, the popup of progress just disappear without any message and still hyperloop disabled.
After checking the Studio logs, I found an error and a suggestion of using the CLI for that.
!ENTRY com.aptana.core 1 0 2016-07-18 20:00:53.309
!MESSAGE (Build 4.7.0.201607130543) [INFO] com.aptana.core/debug/shell/output Process Output:
Failed to enable Hyperloop: Error: TypeError: undefined is not a function
Unable to register the new app with Appcelerator Platform either due to limited connectivity or other unexpected problem. Please retry later using the command 'appc new --import --project-dir /path/to/project' { [Error: ArrowDB apps already exist for this app_guid]
success: false,
description: 'ArrowDB apps already exist for this app_guid',
code: 400,
internalCode: undefined }
When I tried the appc new --import --project-dir ., I got the same message, even removing the app from the platform I can't get hyperloop to work, the other ArrowDB don't seem to have an error (I don't use that personally).
Anything missing?
appc -v = 5.4.0-31
appc ti sdk = 5.4.0.v20160712013704

mobilefirst native ios keychain wrapper issue

I am working on a project for a native iOS app using xcode to develop the project, but including both MobileFirst Platform Foundation capabilities and mobile data capabilities from Bluemix. We are using a shared git repository on IBM DevOps services (jazzhub) to share project source code and work collaboratively on it.
Most of the native apps I have built in the past have been on my own, so this is my first attempt to collaborate using git/xcode working together.
All that is just context for the issue, which is a project using the above environment on my collegues mac build/runs fine. Once I git clone the project and try to run it on my mac I am getting the following error:
*** Assertion failure in -[KeychainItemWrapper writeToKeychain], /tmp/builds/bld-00-20141218-1823-2824648/worklight-ios/framework-xcode-project/NativeSDK-Sources/WorkLight/KeychainItemWrapper.m:311
2015-01-31 13:16:27.657 IBMBankNativeApp[88827:11348297] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'
Above this message in the xcode log I see a secussful initialization of the Bluemix and the call to initialize the MFP connection:
2015-01-31 13:16:27.439 NativeApp[88827:11348297] INFO: IBMBluemix initialization successful.
IBMBluemix SDK Version: 1.0.1.20141124-1240
BlueMix Target: https://mybank.mybluemix.net
applicationId: ea36d23f-....
2015-01-31 13:16:27.530 NativeApp[88827:11348297] IBMData SDK initialization successful.
2015-01-31 13:16:27.580 NativeApp[88827:11348297] ViewController - connectToServer - Initializing ...
2015-01-31 13:16:27.591 NativeApp[88827:11348297] [DEBUG] [WL_CONFIG] -[WLConfig init] in WLConfig.m:68 :: {
"application id" = NativeiOSApi;
"application version" = "1.0";
environment = iOSnative;
host = "192.168.0.17";
platformVersion = "6.3.0.00.20141218-1823";
port = 10080;
protocol = http;
wlServerContext = "/MFProject/";
wlUid = "wY/mbnwKTDDYQUvuQCdSgg==";
}
Before the MFP callback for initialization of the connection the application terminates with the keychain error.
I did not add the keychain access to the project, I'm using cocoapods to set-up bluemix support and wonder if that somehow is adding the keychain support?
I tried removing and running, removing then re-adding they keychain support in the project capabilities, all with the same error.
Is there something checked in and replicated by git that shouldn't be?
Thanks in advance!
Verify that the following Key exists under the Root key in both entitlements-debug.plist and entitlements-release.plist:
Key: keychain-access-groups
Type: Array
Inside the above Key:
Key: Item 0
Type: String
Value: $(AppIdentifierPrefix)worklight.group

Unable to run the app on IOS device

I have created a sample titanium project, I am able to run my app on emulator. But when i try to deploy the same device I'm getting the following error,
[ERROR] : Error details: Code Sign error: No codesigning identities found: No codesigning identities (i.e. certificate and private key pairs) that match the provisioning profile specified in your build settings (“Plan India Feedback App”) were found.
[ERROR] : Error details: CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.1'
Can any one suggest me what is the issue and how to resolve the same.
Phone version is: 6.1.6
Emulator version: 8.1
It indicates that your app id and Provisioning profiles dont match.Please make them same and you would be good to go
Thanks

Resources