|
|
Compilation d'une application en APK depuis Android studio
|
|
|
|
|
|
# envoyer le projet sous android studio
|
|
|
`cd canular`
|
|
|
`ionic capacitor build android`
|
|
|
```
|
|
|
cd canular
|
|
|
ionic capacitor build android
|
|
|
```
|
|
|
1. création d'un certificat
|
|
|
|
|
|
#
|
|
|
Dans la barre principale, sous File/project structure puis sélectionnez le dossier "app" sous Modules, choisir "Signing Configs"
|
|
|
A l'aide du + créer une nouvelle clé avec son mot de passe.
|
|
|
dans la barre principale "Build/generate signed bundle/apk"
|
|
|
|
|
|
![canular_signing](uploads/7290f85ae11d659c7ef17edefc9ce765/canular_signing.png)
|
|
|
- Choisir "apk" puis "next".
|
|
|
- choisir "Create new" pour créer le certificat (ou utiliser un déjà créé)
|
|
|
- les 2 mdps(enfin 4 avec les confirmes) doivent être identiques. Si un certificat existe déjà, il faudra changer l'alias de key,qui reste sur la dernière valeur. Il faut noter quelque par le password, il sera demandé à chaque utilisation du certificat (ici : password : canular)
|
|
|
|
|
|
puis dans l'onglet "build variants", il faut avoir les deux items "release et debug", si l'un est absent, il faut le créer.
|
|
|
la seule chose à ajouter c'est le nom de clé que l'on a précédemment créer dans signing config, le reste peut rester tel quel.
|
|
|
![canular_key](uploads/e092558a04dc6cb5ffdc0c24524c5f15/canular_key.png)
|
|
|
|
|
|
![canular_build](uploads/0aa8c4ae51b5df744d689ec1f1f0ad10/canular_build.png)
|
|
|
- une fois le certificat créé ne pas quitter sur next (le processus plante)
|
|
|
- choisir cancel.
|
|
|
|
|
|
|
|
|
2. vérifier le bundle.
|
|
|
|
|
|
dans la fenêtre de gauche (arborescende des fichiers) sous la section "Gradle scripts", vérifier le fichier "build.gradle", attention, il y en a deux, un pour le projet, un pour le module. C'est celui du module qu'il faut vérifier.
|
|
|
|
|
|
il doit avoir sous la section "signingConfigs" les informations concernant le certificat, sa position sur le disque + mots de passe.
|
|
|
|
|
|
ça doit ressembler à ceci :
|
|
|
|
|
|
```
|
|
|
apply plugin: 'com.android.application'
|
|
|
|
|
|
android {
|
|
|
signingConfigs {
|
|
|
canular {
|
|
|
storeFile file('/home/caluome/Documents/Developpement/canular/signature/canular_certificat2.jks')
|
|
|
storePassword 'canular'
|
|
|
keyAlias 'canular'
|
|
|
keyPassword 'canular'
|
|
|
}
|
|
|
}
|
|
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
|
|
defaultConfig {
|
|
|
applicationId "io.ionic.starter"
|
|
|
minSdkVersion rootProject.ext.minSdkVersion
|
|
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
|
versionCode 1
|
|
|
versionName "1.0"
|
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
|
aaptOptions {
|
|
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
|
|
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
|
|
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
|
|
}
|
|
|
}
|
|
|
buildTypes {
|
|
|
release {
|
|
|
minifyEnabled false
|
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
|
applicationIdSuffix '12'
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
repositories {
|
|
|
flatDir{
|
|
|
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dependencies {
|
|
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
|
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
|
implementation project(':capacitor-android')
|
|
|
testImplementation "junit:junit:$junitVersion"
|
|
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
|
implementation project(':capacitor-cordova-android-plugins')
|
|
|
}
|
|
|
|
|
|
apply from: 'capacitor.build.gradle'
|
|
|
|
|
|
try {
|
|
|
def servicesJSON = file('google-services.json')
|
|
|
if (servicesJSON.text) {
|
|
|
apply plugin: 'com.google.gms.google-services'
|
|
|
}
|
|
|
} catch(Exception e) {
|
|
|
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
|
|
}
|
|
|
```
|
|
|
|
|
|
- Si les informations du certificat sont correctes (et si les mots de passes déclarés sont bien conformes aux mots de passes de la clé), on peut compiler l'application.
|
|
|
|
|
|
- Compilation : dans la barre principale, Build, build bundle /apk / build apk
|
|
|
|
|
|
![canular_valid](uploads/a63056e54c4e025d6830f7b8a54b0afa/canular_valid.png)
|
|
|
|
|
|
|
|
|
- même si le projet a été compilé sous Android studio, l'apk se trouve sous le projet ionic :
|
|
|
|
|
|
ionic/canular/android/app/build/outputs/apk/canular/app-canular.apk
|
|
|
|
|
|
|
|
|
|
|
|
Ensuite dans la barre principale Build/Builde bundle/Apk/Build apk |