louist / cordova-useragent Goto Github PK
View Code? Open in Web Editor NEWAllows you to change your User-Agent for HTTP requests.
Allows you to change your User-Agent for HTTP requests.
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=D:\xiangmu\androidSDK (recommended setting)
ANDROID_HOME=D:\xiangmu\androidSDK (DEPRECATED)
Using Android SDK: D:\xiangmu\androidSDK
Subproject Path: CordovaLib
Subproject Path: app
Command failed with exit code 1: D:\xiangmu\ionicVue\platforms\android\gradlew cdvBuildDebug -b D:\xiangmu\ionicVue\platforms\android\build.gradle
Methods are not returning anything.
get, set, reset.. tried everything. The callbacks are not firing.
returns false on console logging. Can somebody please check.
I am executing the code inside the platform ready. and I have access to the UserAgent object with the methods.
After some digging, I can say the settings object inside UserAgent.java is null.
Since I am getting this error.
"Attempt to invoke virtual method 'java.lang.String android.webkit.WebSettings.getUserAgentString()' on a null object reference"
Update: I am using crosswalk...
Can someone suggest to make it work in crosswalk
Please help.
Thank you.
My ionic cordova build --android
fails with an error code of 1, even if the compile succeeds correctly.
The error message says:
cordova build android --verbose exited with exit code 1.
This error message was found at the end of the build log:
...
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/darrenkarlsapalo/Library/Android/sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app
Running command: /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/gradlew cdvBuildDebug -b /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/build.gradle
> Configure project :app
+-----------------------------------------------------------------
| cordova-android-support-gradle-release: 27.+
+-----------------------------------------------------------------
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preDebugBuild UP-TO-DATE
> Task :CordovaLib:checkDebugManifest UP-TO-DATE
> Task :CordovaLib:processDebugManifest UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :CordovaLib:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :CordovaLib:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript UP-TO-DATE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :CordovaLib:compileDebugRenderscript UP-TO-DATE
> Task :CordovaLib:generateDebugBuildConfig UP-TO-DATE
> Task :CordovaLib:generateDebugResValues UP-TO-DATE
> Task :CordovaLib:generateDebugResources UP-TO-DATE
> Task :CordovaLib:packageDebugResources UP-TO-DATE
> Task :CordovaLib:generateDebugRFile UP-TO-DATE
> Task :CordovaLib:prepareLintJar UP-TO-DATE
> Task :CordovaLib:generateDebugSources UP-TO-DATE
> Task :CordovaLib:javaPreCompileDebug UP-TO-DATE
> Task :CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
> Task :CordovaLib:processDebugJavaRes NO-SOURCE
> Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders UP-TO-DATE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :CordovaLib:mergeDebugShaders UP-TO-DATE
> Task :CordovaLib:compileDebugShaders UP-TO-DATE
> Task :CordovaLib:generateDebugAssets UP-TO-DATE
> Task :CordovaLib:packageDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets UP-TO-DATE
> Task :app:writeDebugApplicationId UP-TO-DATE
> Task :app:processDebugGoogleServices
Parsing json file: /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/app/google-services.json
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:fabricGenerateResourcesDebug
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources
> Task :app:processDebugResources
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:compileDebugNdk NO-SOURCE
> Task :app:compileDebugSources UP-TO-DATE
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:signingConfigWriterDebug UP-TO-DATE
> Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
> Task :app:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
> Task :app:mergeDebugJniLibFolders UP-TO-DATE
> Task :CordovaLib:compileDebugNdk NO-SOURCE
> Task :CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
> Task :CordovaLib:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
> Task :CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
> Task :app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
> Task :app:packageDebug
> Task :app:assembleDebug
> Task :app:cdvBuildDebug
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 9s
45 actionable tasks: 5 executed, 40 up-to-date
Command finished with error code 0: /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/gradlew cdvBuildDebug,-b,/Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/build.gradle
Built the following apk(s):
/Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/app/build/outputs/apk/debug/app-debug.apk
No scripts found for hook "after_compile".
No scripts found for hook "after_build".
[ERROR] An error occurred while running subprocess cordova.
cordova build android --verbose exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
ionic:utils-process onBeforeExit handler: running 2 functions +0ms
ionic:utils-process processExit: exiting (exit code: 1) +31ms
I ran the build instruction again with the verbose flag, and I found one warning:
Your package name is not valid, because 1. name can no longer contain capital letters
This is retrieved from the verbose log:
...
cordova-android-firebase-gradle-release: overriding com.google.firebase:firebase-core:16.0.8 in build.gradle with com.google.firebase:firebase-core:17.0.0
DEBUG: wrote Gradle override file : /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/cordova-android-firebase-gradle-release/kaborrow-cordova-android-firebase-gradle-release.gradle
Executing script found in plugin cordova-android-support-gradle-release for hook "before_build": plugins/cordova-android-support-gradle-release/scripts/apply-changes.js
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/app/build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/cordova-android-support-gradle-release/kaborrow-cordova-android-support-gradle-release.gradle
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Checking for saved plugins that haven't been added to the project
Discovered saved plugin "im.ltdev.cordova.UserAgent". Adding it to the project
No scripts found for hook "before_plugin_add".
No version specified for im.ltdev.cordova.UserAgent, retrieving version from config.xml
No version for im.ltdev.cordova.UserAgent saved in config.xml or package.json
Attempting to use npm info for im.ltdev.cordova.UserAgent to choose a compatible release
Running command: npm view im.ltdev.cordova.UserAgent --json
Command finished with error code 1: npm view,im.ltdev.cordova.UserAgent,--json
Failed to restore plugin "im.ltdev.cordova.UserAgent" from config.xml. You might need to try adding it again. Error: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code E404
npm ERR! 404 'im.ltdev.cordova.UserAgent' is not in the npm registry.
npm ERR! 404 name can no longer contain capital letters
npm ERR! 404
npm ERR! 404 'im.ltdev.cordova.UserAgent@latest' is not in the npm registry.
npm ERR! 404 Your package name is not valid, because
npm ERR! 404 1. name can no longer contain capital letters
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/darrenkarlsapalo/.npm/_logs/2020-01-07T08_38_38_412Z-debug.log
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at /Users/darrenkarlsapalo/git/work/easy-cash/platforms/android/app/src/main/res/xml/config.xml
Merging project's config.xml into platform-specific android config.xml
[Gradle Properties] Preparing Configuration
[Gradle Properties] Appending default configuration properties
[Gradle Properties] Appending custom configuration properties
[Gradle Properties] Updating and Saving File
...
After realizing that it might be a bug related to plugins, I checked to see whether cordova-useragent
existed in the plugins folder of the project. Surprisingly, it did not exist. There was no folder with that name.
Checking the package.json revealed that the plugin was registered as im.ltdev.cordova.UserAgent
instead of cordova-useragent
. Other plugins exist in the plugins folder but there was no folder for the user agent.
Remove and add this plugin.
I tried to remove and re-add the plugin to see if that fixes it.
ionic cordova plugin remove cordova-plugin-useragent
ionic cordova plugin add cordova-plugin-useragent
It fixed it. ๐
This issue occurred to me I think because I worked on two different work stations (my PC, then i moved to my laptop). It might be related to re-building/updating the plugins of an ionic project based on the package.json
file, probably because certain rules (no upper case letters) were enforced by npm, ionic, or cordova.
Hey,
is it planned to support iOS ?
Thanks
As the title says, examples are everything, i have no clue how to use this. at all. so far, this is what i have
it uses
$ cordova plugin list
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-whitelist 1.3.3 "Whitelist"
im.ltdev.cordova.UserAgent 0.1.0 "User-Agent"
this is the current HTML code
<!DOCTYPE html>
<html>
<head>
<title>InAppBrowser.addEventListener Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
var ref1 = UserAgent.set('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0')
var ref2 = window.open('https://devdocs.io', '_blank', 'location=no');
}
</script>
</head>
<body>
</body>
</html>```
I keep on getting this error that the plugin is not installed in my android 7 phone.
even when I have installed this plugin
Native: tried calling UserAgent.set, but the UserAgent plugin is not installed. Install the UserAgent plugin: 'ionic cordova plugin add cordova-plugin-useragent'
I used the same command to install this user agent and the successfuly executed with no errors and allso added the entry in config.xml.
I also ran the npm command after this.
Please help me out.
To reproduce:
cordova platform add android
cordova plugin add https://github.com/LouisT/cordova-useragent
cordova build android
:compileDebugJava
C:\test\101\a\platforms\android\src\im\ltdev\cordova\UserAgent\UserAgent.java:21: error: cannot find symbol
settings = webView.getSettings();
^
symbol: method getSettings()
location: variable webView of type CordovaWebView
1 error
:compileDebugJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJava'.
> Compilation failed; see the compiler error output for details.
It looks like CordovaWebView
is now an interface that doesn't include the getSettings()
function. Source
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.