Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

[Qustion] the hook setting seem not work #1220

Closed
bau720123 opened this issue Sep 15, 2016 · 9 comments
Closed

[Qustion] the hook setting seem not work #1220

bau720123 opened this issue Sep 15, 2016 · 9 comments
Labels

Comments

@bau720123
Copy link

bau720123 commented Sep 15, 2016

hi @macdonst @jcesarmobile
I follow this step and try to copy the png automatically when I am building (I expected)
https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md#additional-resources
I use Cordova 6.3.1 and Cordova-Android 5.2.2

my screenshot as follow
01
02
03

@jcesarmobile
Copy link
Collaborator

can you provide some information?

@bau720123
Copy link
Author

hi @jcesarmobile
my fault,I post too quickly...
I have already update my post
see above

@jcesarmobile
Copy link
Collaborator

can you uncomment the line with the console.log("copying "+srcfile+" to "+destfile); just to check if the hook is being executed or not?

Anyway, in case the hook doesn't work, it might be a Cordova issue, not a plugin issue, unless the documentation you linked is wrong.

@bau720123
Copy link
Author

bau720123 commented Sep 15, 2016

hi @jcesarmobile
after I uncomment the console.log(...) and build again
the "console.log" message appear (under the first line,copying...)

D:\software\Cordova\jqmc>cordova build android --release
copying build\material\icon\android\forward.png to build\platforms\android\res\d
rawable\forward.png
ANDROID_HOME=C:\Users\user\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102
Reading build config file: D:\software\Cordova\jqmc\build.json
Reading the keystore from: D:\software\Cordova\jqmc\android.keystore
Incremental java compilation is an incubating feature.
:preBuild UP-TO-DATE
:preReleaseBuild UP-TO-DATE
:checkReleaseManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:compileReleaseNdk UP-TO-DATE
:CordovaLib:compileLint
:CordovaLib:copyReleaseLint UP-TO-DATE
:CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
:CordovaLib:packageReleaseRenderscript UP-TO-DATE
:CordovaLib:checkReleaseManifest
:CordovaLib:prepareReleaseDependencies
:CordovaLib:compileReleaseRenderscript UP-TO-DATE
:CordovaLib:generateReleaseResValues UP-TO-DATE
:CordovaLib:generateReleaseResources UP-TO-DATE
:CordovaLib:packageReleaseResources UP-TO-DATE
:CordovaLib:compileReleaseAidl UP-TO-DATE
:CordovaLib:generateReleaseBuildConfig UP-TO-DATE
:CordovaLib:mergeReleaseShaders UP-TO-DATE
:CordovaLib:compileReleaseShaders UP-TO-DATE
:CordovaLib:generateReleaseAssets UP-TO-DATE
:CordovaLib:mergeReleaseAssets UP-TO-DATE
:CordovaLib:processReleaseManifest UP-TO-DATE
:CordovaLib:processReleaseResources UP-TO-DATE
:CordovaLib:generateReleaseSources UP-TO-DATE
:CordovaLib:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
:CordovaLib:processReleaseJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:CordovaLib:bundleRelease UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedReleaseLibrary UP-TO-DATE
:preDebugBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareComAndroidSupportAnimatedVectorDrawable2411Library UP-TO-DATE
:prepareComAndroidSupportAppcompatV72411Library UP-TO-DATE
:prepareComAndroidSupportCardviewV72340Library UP-TO-DATE
:prepareComAndroidSupportCustomtabs2340Library UP-TO-DATE
:prepareComAndroidSupportSupportV132340Library UP-TO-DATE
:prepareComAndroidSupportSupportV42411Library UP-TO-DATE
:prepareComAndroidSupportSupportVectorDrawable2411Library UP-TO-DATE
:prepareComFacebookAndroidFacebookAndroidSdk4141Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesAuth921Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesAuthBase921Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesBase921Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesBasement921Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesGcm902Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesIdentity921Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesIid902Library UP-TO-DATE
:prepareComGoogleAndroidGmsPlayServicesTasks921Library UP-TO-DATE
:prepareMeLeolinShortcutBadger114Library UP-TO-DATE
:prepareReleaseDependencies
:compileReleaseAidl UP-TO-DATE
:compileReleaseRenderscript UP-TO-DATE
:generateReleaseBuildConfig UP-TO-DATE
:mergeReleaseShaders UP-TO-DATE
:compileReleaseShaders UP-TO-DATE
:generateReleaseAssets UP-TO-DATE
:mergeReleaseAssets UP-TO-DATE
:generateReleaseResValues UP-TO-DATE
:generateReleaseResources UP-TO-DATE
:mergeReleaseResources UP-TO-DATE
:processReleaseManifest UP-TO-DATE
:processReleaseResources UP-TO-DATE
:generateReleaseSources UP-TO-DATE
:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:compileReleaseJavaWithJavac UP-TO-DATE
:compileReleaseNdk UP-TO-DATE
:compileReleaseSources UP-TO-DATE
:lintVitalRelease
:prePackageMarkerForRelease
:transformClassesWithDexForRelease UP-TO-DATE
:mergeReleaseJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:processReleaseJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:validateReleaseSigning
:packageRelease UP-TO-DATE
:zipalignRelease UP-TO-DATE
:assembleRelease
:cdvBuildRelease

BUILD SUCCESSFUL

Total time: 4.671 secs
Built the following apk(s):
        D:/software/Cordova/jqmc/platforms/android/build/outputs/apk/android-rel
ease.apk

I found the path something wrong
copying build\material\icon\android\forward.png to build\platforms\android\res\d
rawable\forward.png
I trying to figure out why...

@bau720123
Copy link
Author

bau720123 commented Sep 15, 2016

hi @macdonst and @jcesarmobile
found the problem,see my screenshot will know how to solve it
05

and I found...
in this scenario

var filestocopy = [
{
"material/icon/android/forward.png": 
"platforms/android/res/drawable/forward.png"
}, 
{
"material/sounds/beep.wav":
"platforms/android/res/raw/ring.wav"
}, 
];

the hook command can't create a "non exist" folder automatically (although I am already the Administrator)
"material/sounds/beep.wav":
"platforms/android/res/raw/ring.wav"
the "raw" folder is not the default folder in Cordova project
so...I must add the "raw" folder manually

@macdonst
Copy link
Member

@bau720123 can't you just call the node command to create the directory before you try to copy? It's fs.mkdir IIRC.

@bau720123
Copy link
Author

bau720123 commented Sep 16, 2016

hi @macdonst
according to your advise and I google the "fs.mkdir" use method
solved completely
maybe you can consider to update the document

var filestocopy = [
{
"material/icon/android/forward.png": 
"platforms/android/res/drawable/forward.png"
}, 
{
"material/sounds/beep.wav":
"platforms/android/res/raw/beep.wav"
}, 
/*{
"resources/ios/sounds/ring.caf":
"platforms/ios/YourAppName/ring.caf"
},*/ 
];

var fs = require('fs');
var path = require('path');
var rootdir = process.argv[2];

fs.mkdir('platforms/android/res/raw/',0777, function(err)
{
 if(err)
 {
 console.error(err);
 }
  else
  {
  console.log("the directory create success");
  }
});

filestocopy.forEach(function(obj)
{
 Object.keys(obj).forEach(function(key)
 {
 var rootdir = '';
 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));
  }
 });
});

@macdonst
Copy link
Member

macdonst commented Apr 3, 2017

@bau720123 thanks for the heads up, I've updated the docs.

@macdonst macdonst closed this as completed Apr 3, 2017
@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants