爬坑記(ionic-android)

以下有些內容屬於轉載,但是來源忘記了,原作者看見還請留言指出!

 

1、 <ion-searchbar style="padding:10px" placeholder="搜索" (ionInput)="getItems($event)" [(ngModel)]="memInput" (ionClear)="clearInput()"></ion-searchbar>

 

2、模糊查找 顯示或隱藏

for (let index = 0; index < this.mem.memInfo.length; index++) {

if (this.mem.memInfo[index].title.indexOf(inputSer) != -1 ||

            this.mem.memInfo[index].content.indexOf(inputSer) != -1) {

this.mem.memInfo[index].isDisplay = true;

this.searchNum--;

} else {

this.mem.memInfo[index].isDisplay = false;

this.searchNum++;

}

}

 

3、npm報錯

fatal: unable to access 'https://github.com/vstirbu/PromisesPlugin.git/': SSL certificate problem: unable to get local issuer certificate

 

解決:npm config set strict-ssl false

4、com.android.ide.common.process.ProcessException: Failed to execute aapt

可能是maven地址使用google地址的原因

可切換maven地址 以下博客有很多地址可以選擇--http://blog.csdn.net/whbing1471/article/details/53983779

 

----------

更換maven鏡像,列出一個常用的

http://maven.aliyun.com/nexus/content/groups/public/

 

5、div左右滑動

 

(swipe)="onhold($event)"

 

// 左右滑動

onhold(event) {

// console.log(event);

if (event.deltaX < 0) {

// this.blankClick();

// console.log("左");

} else if (event.deltaX > 0) {

this.enterPanel()

// console.log("右");

}

}

 

6、查看端口被佔用

 

netstat -ano  //查看所有端口

netstat -ano|findstr "1080" //查看1080端口的pid

tasklist|findstr "656" //通過pid查看端口被佔用情況

 

7、Suggestion: add 'tools:replace="android:icon"' to element  -----   資源文件打包失敗

在Manifest文件裏添加如下代碼

<manifest  

xmlns:tools="http://schemas.android.com/tools">

 

<application  

tools:replace="android:icon">

 

8、 

Androidstudio3.0 Gradle報錯

 

將 gradle-wrapper.propertie

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

改爲

distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip

當然 maven地址要改代理,不然有牆下載不下來

 

9、npm install---------C:\Program Files\Git\bin\git.EXE ls-remote -h -t https://github.com/vstirbu/PromisesPlugin.git

============> git config --global http.sslverify "false"

============> npm install

第九點轉自 https://blog.csdn.net/u014182690/article/details/78598769

10、ionic打包 android lbs文件裏so包過多

可以在android build.gradle裏面

defaultConfig {

versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))

applicationId privateHelpers.extractStringFromManifest("package")

 

if (cdvMinSdkVersion != null) {

minSdkVersion cdvMinSdkVersion

}

ndk {

abiFilters 'armeabi-v7a'

}

 

}

 

11、angular組件不自動刷新的情況

①先導入模塊

②刷新數據

this.cd.detectChanges();

該方法會檢測所有的數據變化並刷新(不僅僅是刷新這個方法所在的界面)

 

12、ionic 頁面被鍵盤頂起

在AndroidManifest.xml裏的啓動頁activity標籤裏面加上

android:windowSoftInputMode="adjustPan"

 

13、打包安卓報錯

 

ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex

將v4:+改爲v4:23+

 

14、數組去重

例如:arr=[1,2,1,3,1,5,4,2]

Array.from(new Set(arr))=[1, 2, 3, 5, 4]

判斷字符串是否爲空或空格

(new RegExp("^[ ]+$")).test('        ')

爲空返回true

 

15、

 

發佈項目到npm,並且綁定到github

 

 

github創建項目 例如:cordova-plugin-xxx

克隆到本地,進入根目錄

創建package.json ------> 執行 npm init

 

1、登錄npm ------> npm login

-----添加用戶 npm adduser

-----查看當前用戶 npm whoami

 

2、發佈 ----> npm publish

-----部分異常

------1----tunneling socket could not be established, cause=connect ETIMEDOUT 74.122.238.10:88

-----------去掉代理

------2-----npm ERR! no_perms Private mode enable, only admin can publish this module:

------------使用淘寶鏡像導致,需要設置回原來的npm鏡像 ------> npm config set registry=http://registry.npmjs.org

淘寶鏡像npm config set registry=https://registry.npm.taobao.org

 

------2-----npm ERR! you do not have permission to publish "your module name". Are you logged in as the correct user?

------------modules被佔用,需要修改package.json裏面的name,重新npm publish

 

------3----You cannot publish over the previously published version 0.0.1. : cordova-plugin-xiaomo

------------每次上傳需要大於之前的版本號

 

 

3、更新版本

npm version 1.0.1

npm publish

 

16、git

監聽文件 git update-index --no-assume-unchanged package.json

忽略文件 git update-index --assume-unchanged package.json

 

17、js替換文本內所有指定內容

 

data.replace(new RegExp(obj.oldStr, 'g'), obj.newStr)

 

18.獲取當前包名與activity類名

ActivityManager manager= (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.RunningTaskInfo info=manager.getRunningTasks(1).get(0);
info.topActivity.getPackageName();
info.topActivity.getClassName();

19.全局彈窗 利用WindowManager全局彈出 

①dialog

AlertDialog.Builder builder=new AlertDialog.Builder(this);
AlertDialog dialog=builder.setMessage("消息")
        .setPositiveButton("確定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        }).create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.setCanceledOnTouchOutside(true);
if (!dialog.isShowing()){
    dialog.show();
}

②popupwindow

View contentView= LayoutInflater.from(MainActivity.this).inflate(R.layout.popup_layout,null);
PopupWindow popupWindow=new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT,true);
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
popupWindow.setOutsideTouchable(true);
popupWindow.setTouchable(true);
popupWindow.setWindowLayoutType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
popupWindow.showAtLocation(contentView, Gravity.BOTTOM,0,0);

20.Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override

在build.gradle裏面加上下面這段  ionic App也是這樣操作

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

 

21.v4和v7包使用衝突解決辦法

在項目的build.gradle裏面加上 下面這段代碼(強制使用相同支持庫版本,版本號可以改成自己所需要的),圖下有文字,方便複製

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

22.

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onread (net.js:622:25)

安裝3.3.2版本的ws    npm install [email protected]

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章