0%

  • Create a keystore
1
2
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

  • /android文件夹下生成属性文件关联秘钥 key.properties
1
2
3
4
5
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=key
storeFile=<location of the key store file, such as /Users/<user name>/key.jks>

  • /android/app/build.gradle文件里增加load代码
1
2
3
4
5
6
7
8
9
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
...
}
  • 在buildTypes之前增加签名配置代码
1
2
3
4
5
6
7
8
9
10
11
12
13
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
  • 运行编译命令
1
flutter build apk
  • 运行结果
1
2
3
Running Gradle task 'assembleRelease'... Done                     143.3s (!)
✓ Built build/app/outputs/flutter-apk/app-release.apk (79.9MB).

完。

参考:https://flutter.dev/docs/deployment/android

  • 寻找下一个数字,例如输入345,输出354

    思路:从最右边位和上一位对比,如果大,就往前移,移动完,尾数排序,从大到小,保证次大

  • 代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//字符串逆序
NSString *reverseStr(NSString *str){
NSMutableString *string=[[NSMutableString alloc] init];
for(int i=0;i<str.length;i++){
[string appendString:[str substringWithRange:NSMakeRange(str.length-1-i, 1)]];
}
return string;
}

//字符串分成数组
NSMutableArray *separateStringToArray(NSString *str){
NSMutableArray *marr = [NSMutableArray array];
for (NSInteger i = 0; i < str.length; i++) {
[marr addObject:[str substringWithRange:NSMakeRange(i, 1)]];
}
return marr;
}


NSString *findNextLargerNum(NSString *oriNum){


NSMutableString *finalStr = [NSMutableString string];


NSMutableArray *marr = separateStringToArray(oriNum);
for (NSInteger i = marr.count - 1; i > 0; i--) {
NSNumber *lastNum = [marr objectAtIndex:i];
NSNumber *preNum = [marr objectAtIndex:i-1];
if (lastNum.integerValue > preNum.integerValue) {
//截取字符串
NSString *rightStr = reverseStr([oriNum substringWithRange:NSMakeRange(i, oriNum.length - i)]);
NSString *leftStr = [oriNum substringWithRange:NSMakeRange(0,i)];
//第i-1位截取出来
NSString *leftCompareStr = [oriNum substringWithRange:NSMakeRange(i-1, 1)];
//和右边逐个对比
for (int j = 0; j < rightStr.length; j++) {
NSString *rightCompareStr = [rightStr substringWithRange:NSMakeRange(j, 1)];
if (leftCompareStr.integerValue < rightCompareStr.integerValue) {
NSMutableArray *finalArr = separateStringToArray([NSString stringWithFormat:@"%@%@",leftStr,rightStr]);
NSInteger leftIndex = [finalArr indexOfObject:leftCompareStr];
NSInteger rightIndex = [finalArr indexOfObject:rightCompareStr];
[finalArr exchangeObjectAtIndex:leftIndex withObjectAtIndex:rightIndex];
for (NSString *str in finalArr) {
[finalStr appendString:str];
}
break;
}
}
}
}

return finalStr.length?finalStr:oriNum;
}
使用:
1
2
3
4
NSString *str = findNextLargerNum(@"8976");
NSLog(@"======%@",str);
//打印结果
======9678

  • 多张图片快速播放形成动画
  • 动画加上声音形成视频
  • 每一秒播放多少张图片叫做帧,fps,frame per sencode
  • 原始的视频非常大,大在于两个方面,单张图片像素高,每秒播放的图片多,为了方便存储和传输,故需要对原始的视频进行编码
  • 编码是把视频文件进行转换,在保证质量的前提下越小越好,不同的理念诞生不同的算法,分为重质量和重大小,看不同的需求
  • 与编码对应的是解码,尽量还原视频
  • 拍摄视频压缩上传到服务器叫做推流
  • 从服务器获取视频解码播放叫拉流
  • 音频文件也有编码和解码
  • ffmpeg是目前业界最成熟的一套解决方案

今天后台报错

1
2
[_NSPlaceholderData initWithBase64Encoding:]: nil string argument
Foundation -[NSData(NSData) base64Encoding]

经过检查问题发生在字典取出值没有判空就传递给方法使用,细节也要注意,养成良好的编码习惯

1
2
NSString *urlstr = dic[@"imgBase64"];
NSData *data = [[NSData alloc] initWithBase64Encoding:urlstr];

正确的代码

1
2
3
4
5
id obj = dic[@"imgBase64"];
if (obj && [obj isKindOfClass:[NSString class]]) {
NSString *urlstr = (NSString *)obj;
NSData *data = [[NSData alloc] initWithBase64Encoding:urlstr];
}

  • 下载过来,一定要把pod和workspace删掉重新安装,否则会出现奇奇怪怪的问题,比如目标系统不对应,不适配arm64架构等:

The iOS deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 8.0 |

undefined symbols for architecture arm |

今天安装pods发生无法下载问题,

1
Unable to download data from XXX

切换了镜像源解决

  • 查看镜像源
1
gem sources -l
  • 删除淘宝镜像源 -r remove
1
sudo gem sources -r https://ruby.taobao.org/
  • 添加新的镜像源 -a add
1
sudo gem sources -a https://rubygems.org
  • 安装

    1
    sudo gem install cocoapods
  • 成功
    Successfully installed cocoapods-1.10.0
    Parsing documentation for cocoapods-1.10.0
    Done installing documentation for cocoapods after 2 seconds

参考:https://blog.csdn.net/li_ph/article/details/43852845

static lib

a unit of code linked at compile time,which does not change


Dynamic lib

a unit of code and/or assets linked at runtime that may change
only Apple is allowed to create dynamic libraries for iOS


Software Framework

a compiled set of code that accomplished a task,hence,you can actually have a static framework or a dynamic framework,which are typically just the compiled versions of the above.

source:https://stackoverflow.com/questions/15331056/library-static-dynamic-or-framework-project-inside-another-project