---
# System prepended metadata

title: Android 您沒辦法確定 shrink code 是否別的第三方原件也可以用，所以，請使用：
tags: [shrink code, Ljsqlite/Database;, Android Studio, spatialite]

---

# Android 您沒辦法確定 shrink code 是否別的第三方原件也可以用，所以，請使用：

:::info
官網預設 minifyEnabled = false、shrinkResources = false

所以，寫程式的時候，也請把 debug 打開吧！把 minifyEnabled 改成 true 、 shrinkResources 改成 true 
:::


```java=
buildTypes {
        debug{
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            minifyEnabled true

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            // Includes the default ProGuard rules files that are packaged with
            // the Android Gradle plugin. To learn more, go to the section about
            // R8 configuration files.
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
        release {
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            minifyEnabled true

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            // Includes the default ProGuard rules files that are packaged with
            // the Android Gradle plugin. To learn more, go to the section about
            // R8 configuration files.
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
```



### 以卡打車為例：遇到舊版 spatialite 無法使用「混淆」，會出現下圖問題：
![](https://i.imgur.com/SVXFtvN.png)

### 解決方法。

請於 Project > app > proguard-rule .pro 加入以下字串，找好久啊！

```
#Flutter Wrapper
-keep class jsqlite**
-keepclassmembers class jsqlite** {*;}
```




###### 參考資料
* spatialite 官網
https://www.gaia-gis.it/fossil/libspatialite/wiki?name=spatialite-android-tutorial

* shrink-code 官網
https://developer.android.com/studio/build/shrink-code?hl=zh-cn
###### tags: `shrink code` `spatialite` `Ljsqlite/Database;` `Android Studio`　