I have tried everything to get the phonegap facebook plugin working on android, but to no avail. I am using cordova 3.0. I have followed the instructions at: https://github.com/Raffaello/phonegap-facebook-plugin/blob/master/README.md
So the application tag in AndroidManifest.xml looks like:
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:hardwareAccelerated="true"
android:debuggable="true">
<activity android:name="face_login" android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.LoginActivity"
android:label="#string/app_name" />
</application>
The bottom of the config.xml file looks like:
<plugins>
<plugin name="org.apache.cordova.facebook.Connect" value="org.apache.cordova.facebook.ConnectPlugin" />
</plugins>
</widget>
However, I get a huge amount of errors, such as:
CallbackContext cannot be resolved to a type ConnectPlugin.java
cordova cannot be resolved ConnectPlugin.java
error: No resource identifier found for attribute 'hardwareAccelerated' in package 'android' AndroidManifest.xml
PluginResult cannot be resolved to a type ConnectPlugin.java
The import org.apache.cordova.api cannot be resolved ConnectPlugin.java
webView cannot be resolved or is not a field ConnectPlugin.java
I have included the cordova-3.0.0.jar in the buildpath. But still getting all these errors. Any idea's?
That plugin hasn't been updated in 6 months so it probably will not run on Cordova 3.x stream without some modification.
Try it on a Cordova 2.9 to see it it works?
Or you can go through the platform upgrade docs and try to upgrade it yourself to 3.0. Unfortunately there is not a plugin upgrade guide but there should be.
You could also try to use the Network Graph page of Github (I clicked the Fork button) and see if maybe somebody has already ported the plugin to 3.X.
Edit: Looks like there is a fork here that has been updated for 3.0. I have no idea how well it works but I'm sure the author would love pull requests if anything is wrong!
Related
So, I am getting this error on building Android Release. On debug things are fine. It wont even clean the solution.
Things were fine and now after updating to latest Xamarin.
This is what my Droid project top few lines look like
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Xamarin.Build.Download.0.6.0\build\Xamarin.Build.Download.props" Condition="Exists('..\packages\Xamarin.Build.Download.0.6.0\build\Xamarin.Build.Download.props')" />
<PropertyGroup>```
For me, simply restarting the visual studio fixed this issue.
A simple way is set android:usesCleartextTraffic="true" on you AndroidManifest.xml
android:usesCleartextTraffic="true"
Your AndroidManifest.xml look like
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.dww.drmanar">
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:usesCleartextTraffic="true"
android:theme="#style/AppTheme"
tools:targetApi="m">
<activity
android:name=".activity.SplashActivity"
android:theme="#style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I hope this will help you.
android:usesCleartextTraffic="true" did not fix it for me.
I left that attribute in, because it might be enough in the future.
What fixed it was downgrading Xamarin.Build.Download nuget from 0.7.1 to 0.4.12-preview3. 0.4.11 also worked - that was what I was using prior to today, when I updated all nugets.
I also tried 0.7.0 and 0.5.0-rc1. Both had same problem as 0.7.1.
All my Android SDKs and Tools are up-to-date.
Targeting Android 9.0 Pie (API 28), minimum (25), launching to an emulator running Oreo 8.1 (27).
(iOS builds and run successfully with Xamarin.Build.Download 0.7.1; the problem only happened on Android.)
I have Xamarin.Build.Download version 0.8.0 and apparently for me the issue was that the shared code project didn't have a reference to the package, it happens in both, android and iOS, installing the package in the three projects apparently solves the issue.
In my Case this error was hiding another error behind. Using VS2017 V15.9.12, and i was juggling between 2 VS windows with 2 open Xamarin Android projects that had some library projects in common. Restarting the PC fixed the issue.
I am creating android app using Cordova. For that I am using the following commands in cmd.
cordova create example com.path.example ExampleApp
cd example
cordova platform add android
cordova plugin add cordova-plugin-network-information
cordova build android
After these process and copying all webpage codings in assets/www folder successfully.
After this
I import it into eclipse the project is created as MainActivity not ExampleApp. Also I cannot change the App name. I changed app name in config.xml and AndroidManifest.xml file and tried many things. But no use.
so I created a new project and imported. But I cannot import that app because of the new app also have the MainActivity as app name. I googled and searched more over in Stackoverflow and other sites. But cannot fix. Please advise.
We can solve this problem by doing following steps,
Open AndroidManifest.xml file from
platforms->android->AndroidManifest.xml
Change as android:name="Project_name" and
android:label="#string/app_name" in activity
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/app_name" android:launchMode="singleTop" android:name="FLP" android:theme="#android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
After that import your project into eclipse.
I am trying to find out a good document on "How to define custom URL scheme for a Cordova app(on both iOS and Android platforms)".
I have spent hours on internet but couldn't find a good answer. I got some links which are related but not helping me much.
Mine is a Cordova app which runs on iOS and Android platforms. I need to enable my app to be started upon invoking a URL from email(ex: Myapp://).
Please advise me what configuration changes should I maketo my Cordova app to enable this feature.
EDIT:
Android manifest
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.simple.app" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="#android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="com.test.simple" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Url
Launch The App
I know that you are specifically asking for documentation about how to hand-code this yourself, but just FYI there is a nice plugin that will do all of the (considerable amount of!) work for you:
https://github.com/EddyVerbruggen/Custom-URL-scheme
When you install it, you just provide the URL scheme that you want to use to launch your app:
$ cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=myCustomUrlScheme
And that's pretty much all there is to it. Works on Android and iOS.
Android :
In the manifest :
<activity
android:name=".MainActivity"
android:label="#string/activity_name"
android:launchMode="singleTask"
<intent-filter android:label="#string/launcher_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="yourappscheme"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
android:launchMode="singleTask"
Try to use singleTask and singleTop and find the difference.
Both have different functionalities.
For iOS :
So, in your app page create a button called "Redirect to my App" with href as "yourappscheme://".
Open my app
Also there are other parts like Scheme, host.
Consider If you wanna get params from the url, you have to go with Native code.
Say your url is something like : yourappscheme://?username="xxx#gmail.com"
Android:
put this code in OnCreate.
Intent intent = getIntent();
Uri data = intent.getData();
if(data!=null) { //
//get schma
String scheme = data.getScheme(); //
Toast.makeText(getActivity(), scheme, Toast.LENGTH_LONG).show();
if(scheme.contains("yourappscheme")) {
//get parameter
String urltextboxname = data.getQueryParameter("username");
system.out.println(urltextboxname) // it will print xxx#gmail.com
}
}
For iOS :
In your App Delegate :
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
if (!url) {
return NO;
}
// calls into javascript global function 'handleOpenURL'
NSString* jsString = [NSString stringWithFormat:#"handleOpenURL(\"%#\");", url];
[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];
// all plugins will get the notification, and their handlers will be called
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
NSString *myUrlString = [url absoluteString];
if ([myUrlString containsString:#"yourappscheme://"])
{
NSLog(#"Calling Application Bundle ID: %#", sourceApplication);
NSLog(#"URL scheme:%#", [url scheme]);
NSLog(#"URL query: %#", [url query]);
}
return YES;
}
Hope this is clear.
I do this :
go to your folder project and open your cmd on that
next type this below :
cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp
instead of mycoolapp write your app name ,but I just remove (app) on cmd when I paste this but I do not sure it is important or not,so write below in your (index.html) on folder (www) .
<script type="text/javascript" src="js/plugins/LaunchMyApp.js"></script>
and next ,when you add plugin (customurlschema) it added on the plugin folder on your project,so go to the
cordova-plugin-customurlscheme->www->android->LaunchMyApp.js
and copy (LaunchMyApp.js),now as you see that
<script type="text/javascript" src="js/plugins/LaunchMyApp.js"></script>
the (src) is "js/plugins/LaunchMyApp.js" ,so you make this path on your (www) folder and paste (LaunchMyApp.js)
on that .now build your app.if at the first time your app isn't build so remove android with
cordova platform rm android
and add it again to your project,and build twice.may it work for you because I test on project,for work with this plugin you should put like tag below on your html page
Open my app
example:
I write this below:
cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolenglish
so my (href) is like below:
Open my app
and I test it.
.my english isn't very well,so excuse me at first.
UPDATE 2023
As of 2023, PhoneGap is deprecated so using the install script suggested by the accepted answer will fail every time. There is no candidate for the installation of PhoneGap.
If you try to run this in your terminal :
cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=myCustomUrlScheme
This will return this error :
Failed to fetch plugin
https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git via
registry. Probably this is either a connection problem, or plugin spec
is incorrect. Check your connection and plugin name/version/URL.
CordovaError: Error: No git binary found in $PATH
TLDR
To install the custom-url-scheme plugin run this :
sudo cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=myapp://redirect.html?redirect&return=true
Then on your server you should have a page :
redirect.html
Click here to open app
I'm facing an issue in which the Android soft keyboard is appearing over the last edittext field on the page. Suggested solutions include changing the windowSoftInputMode, so I added the following preference in the config.xml file:
<preference name="android-windowSoftInputMode" value="adjustResize|stateHidden" />
However, after I do my build, the AndroidManifest.cordova.xml file in the release folder always has a windowSoftInputMode of "adjustResize" and thus nothing changes when I run the app.
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/activity_name" android:launchMode="singleTop" android:name="CordovaApp" android:theme="#android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Does anyone know if this setting can be overridden and if so, what the mechanism is for doing so? I'm using Visual Studio (2013 Update 4) Tools for Apache Cordova CTP3.
I've had a similar issues in the past, here's how i solved it.
Create a custom AndroidManifest.xml file in the res\native\android folder. All the info in this file will get copied to the debug folder (and will overwrite what is contained in the config.xml file) when you do a build for Android Platform.
Here's a link to the MSDN documentation which has alot more info about custom configurations for the different platforms:
https://msdn.microsoft.com/en-us/library/dn757053.aspx
I'm trying to complete this tutorial from the Android Page http://developer.android.com/training/basics/firstapp/starting-activity.html But I Eclipse throws this error: "No resource identifier found for attribute 'parentActivityName' in package 'android'" I have included the android-support-library.
Here is the whole AndroidManifest.xml code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
android:parentActivityName appears first in Android 4.1 (API level 16). You need to have the latest 4.1 SDK to compile this.
To add to David Wasser's answer, if you use Eclipse and have the correct SDK library installed but still have this error, it means that while the correct library is installed Eclipse does not use it for this project.
To change that, go to your project's Properties (right-click on its name in the Package Explorer and it's the last but one option), select Android in the left hand column and you should have a list called Project Build Target. Then:
Select the appropriate target (Android 4.2.2 or Google APIs for Platform 4.2.2 in this instance)
Save your Manifest file (make a trivial edit if necessary)
Once it is saved Eclipse will process it and those errors should disappear as Eclipse finds the resource identifier in its new build target.
This error will also happen if you don't have the exact version of the SDK that the sample app uses as it's build target. Following the same steps as Julien describes above and choosing an SDK you have locally will fix it.
In IntelliJ IDEA, you need to change in Platform Settings->SDKs->Android something->Build target TO 4.1+.
If you don't see the option, you need an SDK version 4.1 or higher (API level 16+).