logo
down
shadow

Android/Cordova: Where to add files?


Android/Cordova: Where to add files?

By : user2948672
Date : November 15 2020, 06:54 AM
will help you Once a cordova project has been created. It has a root /www folder where all resources are eligible to be shared on the added platforms (which you intends to add)
You should modify here. though its possible to modify resources per platform. (read more API)
code :


Share : facebook icon twitter icon
Where do Android res Files go in Cordova?

Where do Android res Files go in Cordova?


By : David Blair
Date : March 29 2020, 07:55 AM
wish helps you I was able to figure out what appears to be the best practice currently. I wanted to document this for others as well.
I created a folder for the resources I needed and then wrote a custom hook to copy the files. Here is a great example that I used from http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/:
code :
#!/usr/bin/env node

// This hook copies various resource files 
// from our version control system directories 
// into the appropriate platform specific location
//


// configure all the files to copy.  
// Key of object is the source file, 
// value is the destination location.  
// It's fine to put all platforms' icons 
// and splash screen files here, even if 
// we don't build for all platforms 
// on each developer's box.

var filestocopy = [{
    "config/android/res/drawable/icon.png": 
    "platforms/android/res/drawable/icon.png"
}, {
    "config/android/res/drawable-hdpi/icon.png": 
    "platforms/android/res/drawable-hdpi/icon.png"
}, {
    "config/android/res/drawable-ldpi/icon.png": 
    "platforms/android/res/drawable-ldpi/icon.png"
}, {
    "config/android/res/drawable-mdpi/icon.png": 
    "platforms/android/res/drawable-mdpi/icon.png"
}, {
    "config/android/res/drawable-xhdpi/icon.png": 
    "platforms/android/res/drawable-xhdpi/icon.png"
}, {
    "config/android/res/drawable/splash.png": 
    "platforms/android/res/drawable/splash.png"
}, {
    "config/android/res/drawable-hdpi/splash.png": 
    "platforms/android/res/drawable-hdpi/splash.png"
}, {
    "config/android/res/drawable-ldpi/splash.png": 
    "platforms/android/res/drawable-ldpi/splash.png"
}, {
    "config/android/res/drawable-mdpi/splash.png": 
    "platforms/android/res/drawable-mdpi/splash.png"
}, {
    "config/android/res/drawable-xhdpi/splash.png": 
    "platforms/android/res/drawable-xhdpi/splash.png"
}, {
    "config/ios/Resources/icons/icon-72.png": 
    "platforms/ios/YourAppName/Resources/icons/icon-72.png"
}, {
    "config/ios/Resources/icons/icon.png": 
    "platforms/ios/YourAppName/Resources/icons/icon.png"
}, {
    "config/ios/Resources/icons/icon@2x.png": 
    "platforms/ios/YourAppName/Resources/icons/icon@2x.png"
}, {
    "config/ios/Resources/icons/icon-72@2x.png": 
    "platforms/ios/YourAppName/Resources/icons/icon-72@2x.png"
}, {
    "config/ios/Resources/splash/Default@2x~iphone.png": 
    "platforms/ios/YourAppName/Resources/splash/Default@2x~iphone.png"
}, {
    "config/ios/Resources/splash/Default-568h@2x~iphone.png": 
    "platforms/ios/YourAppName/Resources/splash/Default-568h@2x~iphone.png"
}, {
    "config/ios/Resources/splash/Default~iphone.png":
    "platforms/ios/YourAppName/Resources/splash/Default~iphone.png"
}, {
    "config/ios/Resources/splash/Default-Portrait~ipad.png": 
     "platforms/ios/YourAppName/Resources/splash/Default-Portrait~ipad.png"
}, {
    "config/ios/Resources/splash/Default-Portrait@2x~ipad.png": 
    "platforms/ios/YourAppName/Resources/splash/Default-Portrait@2x~ipad.png
}, ];

var fs = require('fs');
var path = require('path');

// no need to configure below
var rootdir = process.argv[2];

filestocopy.forEach(function(obj) {
    Object.keys(obj).forEach(function(key) {
        var val = obj[key];
        var srcfile = path.join(rootdir, key);
        var destfile = path.join(rootdir, val);
        //console.log("copying "+srcfile+" to "+destfile);
        var destdir = path.dirname(destfile);
        if (fs.existsSync(srcfile) && fs.existsSync(destdir)) {
            fs.createReadStream(srcfile).pipe(
               fs.createWriteStream(destfile));
        }
    });
});
Cordova Error on Build Only for Android: com.android.dex.DexException: Multiple dex files define Landroid/support/annota

Cordova Error on Build Only for Android: com.android.dex.DexException: Multiple dex files define Landroid/support/annota


By : Sinan
Date : March 29 2020, 07:55 AM
Does that help Had the same problem, adding the following lines to the build.gradle file located in platforms/android did it for me.
code :
configurations {
   all*.exclude group: 'com.android.support', module: 'support-v4'
}
apply plugin: 'android'
Cordova gives "Adding android project.." on 'cordova platform add android' but when 'cordova build android' is

Cordova gives "Adding android project.." on 'cordova platform add android' but when 'cordova build android' is


By : Yuriy K
Date : March 29 2020, 07:55 AM
This might help you Previous people have had similar problem.
Please try to add a specific android version by
Unable to install custom cordova plugin to android platform after updating to cordova android 7.0.0

Unable to install custom cordova plugin to android platform after updating to cordova android 7.0.0


By : Mathan
Date : March 29 2020, 07:55 AM
it helps some times I have created one cordova plugin and it was working fine with old cordova android versions (< 7.0.0). once i updated to cordova-android 7.0.0 from cli am unable to install my plugin even after updating plugin.xml based on cordova blog. , Fixed by updating target for the two files.
for aar lib file :
code :
<source-file src="src/android/abc/abc.aar" target-dir="app/src/main/libs" framework="true" />
<source-file src="src/android/com/abc/CordovaPluginAABC.java" target-dir="src/com/rak/abc" />
How to give permission to files in android using cordova

How to give permission to files in android using cordova


By : user3714949
Date : March 29 2020, 07:55 AM
Does that help I solved it the only thing I was doing wrong is that I was passing the name of file with its uri, we only need to pass the uri in fileChooser.open() function. I will post the client side code. Here is the solution :-
SOLVED CLIENT CODE
code :
<template>
    <div><br>
        <hr><br><br>
        <v-btn color="warning" @click="selectFiles()">Upload Files</v-btn>
    </div>
</template>

<script>
export default {
    data() {
        return {
        }
    },
    mounted() {
        document.addEventListener("deviceready", onDeviceReady , false);
        function onDeviceReady() {
            console.log(window.FileTransfer);
        }
    },
    methods: {
        selectFiles() {
            window.fileChooser.open((file) => {
                this.upload(file.uri);
            })
        },
        upload(fileURL) {
            var options = new window.FileUploadOptions();
            options.fileKey = "image";
            options.httpMethod = 'POST';
            options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
            options.mimeType = "image/jpeg";
            var ft = new window.FileTransfer();
            ft.upload(fileURL, encodeURI("http://192.168.1.111:8000/user/fileUpload"), (r)=>
            { 
                alert("uploaded successfully..")
                console.log("Code = " + r.responseCode);
                console.log("Response = " + r.response);
                console.log("Sent = " + r.bytesSent);}, (error)=>{
                alert(JSON.stringify(error));
                console.log("upload error source " + error.source);
                console.log("upload error target " + error.target);
            }, options);
        }
    }
}
</script> 
Related Posts Related Posts :
  • Android Studio gradle build failed for hello world app
  • Slide a layout up from bottom of screen
  • Play HTML5 video in iOS/Android native media player
  • How to rescale a bitmap file in android?
  • No view found for id 0x for fragment after rotation?
  • Define different themable styles to the same widget types
  • ProGuard not working in my app
  • FragmentTransaction from BaseAdapter
  • Connecting multiple devices in a Wifi Direct group
  • Why TabActivity is deprecated in android
  • How to capture low resolution picture using android camera
  • android preferenceactivity padding in landscape orientation
  • How can I store cookie in webview?
  • Passing variables from one activity to another
  • Create Multicolored Pie Chart in Android Studio
  • how to kill progress dialog in android
  • Show Error on the tip of the Edit Text Android
  • How do I use getWindowManager() by another java file
  • fetching images from gallery on android phones with internal storage
  • How to discover devices like Google TV and Nexus-Q using MediaRoute API on Android?
  • "Unfortunately your app stopped working"- Facebook Integration for Android
  • How to animate button in android?
  • Resource Not Found Exception in class without context or activity
  • Launching Android Netflix App And Passing Video Id
  • Making a Phone Call with a Number Extension
  • NullPointerException at BoringLayout.isBoring is anything but boring
  • java.lang.RuntimeException: Unable to get provider
  • Testing custom Views with Robolectric
  • tools:listheader doesn't work although tools:listitem does
  • oppo, vivo app kill notification not coming in android fcm
  • OnClick Method could not function correctly with if else statement
  • Best method to download image from url in Android
  • How can I open Drawer Layout moving all the view and not just slide over?
  • how to show profile pictures of friends in a list view?
  • Creating TimePickerDialog with custom style in Android
  • Android 2.3.6 support library v7 option menu is missing
  • need of vblank in Display subssytem
  • Android MP4 stream - Video cannot be played
  • FastAdapter: Undo button does not show up after swipe
  • What are reasons to pass getActivity as the LifecycleOwner to the LiveData's observe method in a fragment?
  • Implement Face Recognition in Android
  • Titanium studio cannot run "titanium" command in terminal
  • How to execute command line ffmpeg commands programatically in android?
  • Make Android List Items clickable with each item pointing to a different link
  • listview runs successfully, but nothing is display in emulator
  • How to zoom in a bitmap with high resolution?
  • Passing listView data through intent
  • Google map route direction show by arrows in android v2
  • how to start "uiautomator test run" from android code?
  • Proguard in Android Library
  • Alarm Clock from GIT - Gives error - Android
  • Mock injection using Mockito - Android
  • Get Bitmap from universal image loader
  • Unable to include custom font in android
  • Basics on using logcat in Android development
  • Android: Clear cache programmatically
  • Android: pass object without serialization
  • Can not scroll and click item on gridview inside scrollview
  • Android device keeps disconnecting from adb / eclipse
  • Volley cannot create cache directory. Could not clean up file
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org